Question by
Dorscherl · Feb 02 at 06:30 AM ·
quaternionlookrotation
Quaternion help with top down camera
I have my camera set to follow directly overhead from the player. I need the camera to look directly at the player but I also want it to rotate so the player is always facing the top of the screen. The kicker is I need this to work on a planet-like environment.
Here's what I have:
Vector3 origin = FollowTarget.position + FollowTarget.TransformDirection(FollowOffset);
Vector3 position = origin + FollowTarget.up * _height;
transform.position = position;
Quaternion rotation = Quaternion.LookRotation(origin - position);
transform.rotation = rotation;
With this the camera looks at the player target but does not rotate with the player's direction.
Comment