Skip to content

Instantly share code, notes, and snippets.

@FareedMasood
Created May 3, 2017 06:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FareedMasood/5a0023f56134285594e165015a6ba9b1 to your computer and use it in GitHub Desktop.
Save FareedMasood/5a0023f56134285594e165015a6ba9b1 to your computer and use it in GitHub Desktop.
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);
}
}
}
@FareedMasood
Copy link
Author

This is a C# file which enables the user to move around in the VR android application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment