- Home /
Question by
varian97 · Jul 10, 2017 at 05:17 PM ·
rotationvrunity5camera rotate
Google Cardboard, camera rotation not working correctly
I want to make a simple VR game, the game only consists of a plane and a ball. The goal of the game is to make the ball balance, keeping it on the plane by tilting the camera using head movement. Here is the script that I attached to the ball :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MarbleController : MonoBehaviour {
private Rigidbody rb;
public Camera gameCamera;
public float collisionFactor = 10.0f;
void Start () {
rb = GetComponent<Rigidbody> ();
}
void Update () {
rb.AddForce (new Vector3(gameCamera.transform.rotation.z,0,gameCamera.transform.rotation.x) * collisionFactor);
}
}
I tested it on the Unity Editor ( rotate the camera by using ctrl + mouse left and right ), and it worked. However when I build it to the android, the rotation become false. If I tilt my head to the left, the ball go to the right and vice versa.
Anyone knows the problem on my work ?
Comment