Can somebody tell me how to do head based steering? I know how to do it while mooving only camera, but i want to moove object by head and camera to follow the object.
I need this because i want to implement game logic to the object(it will aleso work for me if i can treat camera as an normal object).
I found this code for steering only camera:
public float speed = /* some number */;
private CardboardHead head;
head = // find the CardboardHead
// head = Camera.main.GetComponent<StereoController>().Head;
// or, make the variable public and use drag-and-drop in the Editor
transform.position += speed * head.Gaze.direction;
I'm starting to make games for unity so if I made some mistakes please correct me.
if you do, then there is a prefab called cardboard main, put it in the scene, then if you see there is a game object called Head inside it and it contains CardboardHead script. So here is in your script:
public GameObject head; // drag the Head gameobject to here or you can just get it from the start
if (!head) // if you didn't drag the gameobject
head = FindObjectOfType<CardboardHead>().gameObject;
transform.position += speed * head.transform.forward; // it is better to multiply by Time.deltaTime
also btw why it is tagged as Java?
So here is what I did. I split the 'visual' and 'mechanic'. I removed the Mesh Renderer from the player, freeze its rotation for the rigidbody. I made a new child for the 'visual' it has a Script called Rotate.cs and removed its collider.
Changes to script:
in Forward.cs use the rb.AddForce(transform.forward * speed); back, and in Rotate.cs just use