- Home /
How can I make the camera follow the player's rotation only on the z axis?
I am making a game, something like Ketchapp's Twist. How can I make the camera rotate along with the player only on the Z axis? I did this to make the camera follow the player's position -
public GameObject player;
private Vector3 offset;
void Start()
{
offset = transform.position - player.transform.position;
}
void Update()
{
Vector3 pos = player.transform.position + offset;
transform.position = new Vector3(pos.x,transform.position.y,pos.z);
}
But an error pops up when I try the samre thing with the rotation. Anyone have suggestions?
P.S. If you can make the platforms on which the player moves rotate instead of the camera, it's fine too.
Answer by toddisarockstar · May 08, 2017 at 11:24 PM
if this code is working correctly for position, there is no reason it wouldnt work for rotation.
every where is says "transform.position" change it to:
transform.eulerAngles
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to rotate camera diagonally over players shoulder while still facing towards players direction 0 Answers
How to rotate camera diagonally over players shoulder while still facing towards players direction 0 Answers
How do I rotate a camera on the Z axis relative to it's rotation on the X axis. 1 Answer