Hi,
Preface: I am pretty much totally new to C#, but I had some previous python experience doing some small study projects on Arduino.
I am trying to utilize the google cardboard SDK package for the stereoscopic camera effect, and child it to a parent camera rig, where I used the basic Unity translate script from the tutorials page.
The information I am trying to find is how to modify the movement code attached to my CameraRig, to be related to the head angle’s Z direction, but rotated down into the global XZ plane (the magenta vector would be the one I hope to use in the CameraRig script). See this diagram:
This is simply just beyond me to figure out on my own.
The CameraRig movement script:
using UnityEngine;
public class RigMovement: MonoBehaviour
{
public float moveSpeed = 10f;
public float turnSpeed = 50f;
private Rigidbody playerRigidbody;
void Awake()
{
//Get references
playerRigidbody = GetComponent<Rigidbody>();
}
void Update()
{
if (Input.GetKey(KeyCode.UpArrow))
transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
if (Input.GetKey(KeyCode.DownArrow))
transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime);
if (Input.GetKey(KeyCode.LeftArrow))
transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime);
if (Input.GetKey(KeyCode.RightArrow))
transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
}
}
I am unsure of what to link here for the Cardboard SDK, but I downloaded it from this location, and attached the camera asset as a child to the rig: Quickstart for Google VR SDK for Unity with Android | Google for Developers
I imagine it would be a GetComponent from the SDK script where I should begin searching, but I think I have to figure out how to make a derivative of a vector a public element?
Thanks for any help you can provide!
Best,
Kevin