resonantdoghouse
7/11/2018 - 4:07 AM

Unity 3d VR Interaction Basic.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraMovement : MonoBehaviour
{
	public Transform vrCamera;
	public float speed = 3.0f;
    public bool moveForward;
	private CharacterController cc;

    void Start()
    {
      cc = GetComponent<CharacterController>();
    }

	void Update(){
		if (Input.GetButton("Fire1"))
    {
			moveForward = true;
    }
		else {
			moveForward = false;
		}
		if(moveForward){
			Vector3 forward = vrCamera.TransformDirection(Vector3.forward);
			cc.SimpleMove(forward * speed);
		}
	}

}