- Home /
Question by
uanmanarmy · Mar 26, 2014 at 05:12 PM ·
camerarotaterotatearoundorbit
Camera Orbit Rotation Problem
Hello guys, I need some help. This is the peace of code which is used to rotate my camera.
Now if I'm rotating it, my camera makes a circle while rotating, but I want it just to rotate only the direction and not to make a big Orbit.
if (Input.GetMouseButton(0))
{
xDeg += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
yDeg -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
////////OrbitAngle
//Clamp the vertical axis for the orbit
yDeg = ClampAngle(yDeg, yMinLimit, yMaxLimit);
// set camera rotation
desiredRotation = Quaternion.Euler(yDeg, xDeg, 0);
currentRotation = transform.rotation;
rotation = Quaternion.Slerp(currentRotation, desiredRotation, Time.deltaTime * zoomDampening);
transform.rotation = rotation;
}
For a better clarification please see this picture. https://copy.com/kGTGO9htTL8D
Comment
Were you unable to use transform.Rotate? (http://docs.unity3d.com/Documentation/ScriptReference/Transform.Rotate.html) You could Rotate around the world.up and world.right vectors so the camera rotates properly.
Your answer
Follow this Question
Related Questions
Based on touch rotate camera object 0 Answers
Help with camera movement using mobile input 0 Answers
RotateAround() faster than rotate 1 Answer
Orbit around an object 0 Answers
Slowly orbit camera on keypress 1 Answer