Smooth Follow Camera Rotate on Z-Axis?

Hey Unitarians!

I’m using the normal SmoothFollow.js script that unity gives me, but I can’t get the camera to rotate on the z-axis, as it does in this game.

What should I do to be able to turn in the z-axis?

I’d recommend coding your own chase camera from scratch, so it does exactly what you want it to do. It looks like all they’re doing for that cube game is creating Z rotation related to the player’s X velocity or X input.

If you know the maximum X velocity the player can achieve, you can form a direct relationship to the camera’s Z rotation:

// get x velocity as % of total possible
float p = Mathf.Abs( player.velocity.x ) / maxPlayerXVelocity
// sign and convert to desired z cam rotation
float CameraZ = Mathf.Sign( player.velocity.x ) * p * maxCamZRotation;

Here’s one way to rotate on the z axis:

transform.Rotate(0, 0, Input.GetAxis("Horizontal"), Space.World);