Hi, I'm quite new about unity and I cannot figure out how to make my camera move and rotate at the same time when I click a specific button on my interface.
Let me explain more in detail what I need.
I've added a GUI interface in my project and when I press a specific button, I want that my camera makes a smooth movement while adjusting its rotation (and maybe its field of view). The problem is that all those translations and rotations happen along more than one axes:
I've found a lot of information about how to make GameObjects move or rotate using mouse coordinates, but not one matched my need. Does someone know how to solve this problem with a script?
this is the function I wrote
It is triggered by one of the buttons in my GUI and it realize only a smooth translation. Do you know how can I improve it to have also the rotation?
The method you are using here to translate the movement target is entirely in world space, which is good because if the object rotates, that won't affect its movement direction.
You can Lerp rotation in a similar way to how you are Lerping the position. Check out Quaternion.Lerp and Quaternion.Slerp (http://unity3d.com/support/documentation/ScriptReference/Quaternion.html). You can then lerp from a current rotation to a new rotation.
If you are unsure how quaternions work, you can probably get by without knowing the internals of it all. There are a few static Quaternion functions that you can use to create a quaternion that represents a rotation direction. For example, Quaternion.Euler(x,y,z) will give you a Quaternion that represents a rotation with the given x,y,z angles.
You could then say something like
answered Nov 21 '11 at 05:52 PM