- Home /
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?
Answer by AlwaysSunny · Sep 01, 2014 at 10:37 PM
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;
That's a great idea! However, How would I go about creating my own chase camera?
That's not something anyone can answer for you. Like all things in game program$$anonymous$$g, it depends on the nature of your project and your desired outcome. With practice you'll become familiar with Unity and 3D math operations, able to program whatever behavior you want.
Ok. I'll keep messing around and trying out tutorials until I figure something out; Thanks for the tip though!
Answer by kacyesp · Sep 01, 2014 at 10:39 PM
Here's one way to rotate on the z axis:
transform.Rotate(0, 0, Input.GetAxis("Horizontal"), Space.World);
I have code that does a similar thing but the code in the original script negates any movement in the z axis with transform.lookat
Your answer
Follow this Question
Related Questions
Rotating camera problem C# Android 2 Answers
Flip over an object (smooth transition) 3 Answers
How to make an object face the mouse in a non-2D world 1 Answer
Problem with Camera rotation script 3 Answers
Distribute terrain in zones 3 Answers