I'm trying to get a camera in my scene to smoothly rotate down (something like 10 degrees) and then back up to its original position (like a security camera).
I think Mathf.Lerp is probably the way to go, but I can't figure how to stop at the determined place and then get back up.
It should only do this when specifically activated (by a keypress or another function). And before rotating, a Boolean value should be turned true and when finished, it should turn false (this would allow my other functions to notice the rotation is happening and not interfere with it).
asked Aug 08 '11 at 03:27 PM
If you don't mind using the Animation Editor, this would be easy to do that way, and you could even insert events at the start and end to set that boolean for you.
But you could also use Transform.Rotate http://unity3d.com/support/documentation/ScriptReference/Transform.Rotate.html Several ways to do it, you could have a coroutine which yields while it's going down, then sets the up direction and yields again, or you can have limits you check in an Update function ('current angle' vs some lower and upper limits).