New To The Forum? Click Here To Read The How To Guide. -- Developers Click Here.

Camera Offset from Player Problem, inaccurate collision (SOLVED)

amadeus.bojiucamadeus.bojiuc Posts: 2
NerveGear
edited July 17 in Unity
Basically my camera is always offset from the player due to the head tracking. This is problematic because the player handles the collisions. The camera is a child of the player and should remain at it's origin.

How can I make it so that that the head tracking moves the player instead of the camera?

Basically I want the tracking to move the player and the camera together, not the camera away from the player.



Comments

  • imperativityimperativity Posts: 1,597 Oculus Staff
    Hi,

    Welcome to the Oculus Developer Forums.

    Which version of Unity and Oculus software are you using?

    Basically I want the tracking to move the player and the camera together, not the camera away from the player.


    The Roll-a-ball vr tutorial includes a script on how to achieve this (non VR game):

    https://unity3d.com/learn/tutorials/projects/roll-ball-tutorial/moving-camera?playlist=17141

  • amadeus.bojiucamadeus.bojiuc Posts: 2
    NerveGear
    The latest version of both (Unity 5.6.3)

    I found a solution for this.
    Create a parent object for the camera inside the player object. Make the camera a child of this cam holder object.

    The cam holder's position will be the opposite of whatever the camera's offset is. So if the camera is offset by -1, then this object will be offset by 1 making it centered on the player. This can be achieved with a simple line of code on the cam holder object.

    public Transform Main_Camera;

    transform.localPosition = new Vector3 (-Main_Camera.localPosition.x,0, -Main_Camera.localPosition.z);

    Simple as that.

Sign In or Register to comment.