i am making a 2D game that has 3d rotation with camera i can make it rotate and change axis but i want to make it smoothly transition how can i make smooth rotation ? and smooth movement ? this is how i do it : transform.Rotate(0,90,0); i want it to be smooth and in movement there is Distance from player i change the distance from X 10 to X = 0 and Z 0 to Z = 10 but all happen instantly how can i fix this ?
(comments are locked)

Smooth in Unity means Lerp! (Slerp, for Quaternions) You should use the "Lerp filter", a smart use of Lerp that behaves like a smoothing filter. Attach this script to the camera: var speed: float = 2.5; var cameraAngles: Vector3; // the target angles around x, y and z var cameraPos: Vector3; // the target position function Start(){ cameraAngles = transform.eulerAngles; cameraPos = transform.position; } function Update(){ transform.position = Vector3.Lerp(transform.position, cameraPos, speed*Time.deltaTime); var newRot = Quaternion.Euler(cameraAngles); // get the equivalent quaternion transform.rotation = Quaternion.Slerp(transform.rotation, newRot, speed*Time.deltaTime); } You just set the angle and position you want in cameraAngles and cameraPos, and the camera goes smoothly to the new rotation/position. thank you.
Oct 08 '11 at 01:25 PM
midomido
(comments are locked)

Hi, I don't exactly understand what you mean, but have a look at Quaternion.Slerp() for smooth interpolation of rotation and for translation Vector3.Lerp(). Torsten
(comments are locked)
