- Home /
Rotate around object smoothly
Hi,
I am using a modified MouseOrbit script to rotate a camera around an object. It is similar to the one in this thread: http://answers.unity3d.com/questions/64873/smooth-mouse-orbit.html
Now I want to be able to get the camera facing each "90 degree side" of the object by pressing the right or left arrow. If the camera is between two sides it rotates to the next one.
My problem is that if I want it to look smooth (and relatively fast), it overshoots the given value. It only works without the smooth because it stops immediately at the right angle.
Anyone has an idea how to do this? I am open to completely different methods...
Thank you
EDIT:
I found a way looking at a recent post. I didn't think of using a parent empty gameObject as a pivot point. The solution is simple after that.
Please tidy this question up by transferring your edit to an answer and then accepting it. It would be good to add a little more detail for anyone following.
Answer by lapoune · Jul 23, 2012 at 07:23 PM
Ok I didn't know how to close it I didn't think of answering myself. Basically I parented the camera to an empty GameObject, and then you can just apply any kind of rotation to that pivot point and the camera will turn with it, thus creating the same effect as rotateAround but with damping and precision. Seems simple but I didn't think of it before seeing another question...
If it's an answer it can be upvoted ;)
I imagine you can accept your own answer in a few days probably.
Your answer
Follow this Question
Related Questions
Smooth Attached Object movement 1 Answer
How Can I Smooth This Camera Code 0 Answers
Camera, Look rotation, smoothly? 0 Answers
smoothly rotate camera around an object with momentum 0 Answers