-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVrlookwalk
More file actions
40 lines (30 loc) · 896 Bytes
/
Vrlookwalk
File metadata and controls
40 lines (30 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Vrlookwalk : MonoBehaviour {
public Transform vrcam;
public float toggleangle = 30.0f;
public float speed = 3.0f;
public bool moveforward;
public CharacterController cc;
// Use this for initialization
void Start () {
cc = GetComponentInParent<CharacterController>();
}
// Update is called once per frame
void Update () {
if (vrcam.eulerAngles.x >= toggleangle && vrcam.eulerAngles.x < 90.0f)
{
moveforward = true;
}
else
{
moveforward = false;
}
if (moveforward==true)
{
Vector3 forward = vrcam.TransformDirection(Vector3.right); //create a new vector3 and know the forward direction of the vr camera
cc.SimpleMove(forward * speed);
}
}
}