Created
May 3, 2017 06:11
-
-
Save FareedMasood/5a0023f56134285594e165015a6ba9b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class cha : MonoBehaviour { | |
public Transform vrCamera; | |
public float toggleAngle = 30.0f; | |
public float speed = 3.0f; | |
public bool moveForward; | |
private CharacterController cc; | |
// Use this for initialization | |
void Start () { | |
cc = GetComponent<CharacterController> (); | |
} | |
// Update is called once per frame | |
void Update () { | |
if (vrCamera.eulerAngles.x >= toggleAngle && vrCamera.eulerAngles.x < 90.0f) { | |
moveForward = true; | |
} | |
else { | |
moveForward = false; | |
} | |
if (moveForward) { | |
Vector3 forward = vrCamera.TransformDirection (Vector3.forward); | |
cc.SimpleMove (forward * speed); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a C# file which enables the user to move around in the VR android application.