Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
amadeus.bojiuc's avatar
amadeus.bojiuc
Honored Guest
9 years ago

Camera Offset from Player Problem, inaccurate collision (SOLVED)

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.



1 Reply

Replies have been turned off for this discussion
  • 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.