- Home /
Rotating a bone upwards relative to camera.
Hello, I have been trying to achieve this result but to no avail. I want to rotate a limb upwards relative to space.world or camera view. So that when a user presses UP, the bone rotates upward, or Down for downward. This is difficult to explain so I attached a picture to illustrate the desired result. As you can see, I have the horizontal movement exactly as I want it. It's just the vertical movement I'm having problems with.
I feel the answer is easy to someone who has experience, but I have trouble even explaining my desired result into google to find an answer. So your help is greatly appreciated.
targetLimb.transform.Rotate(-yy, 0, 0, Space.World);
This code would work if I can get the angle to the horizontal center (pointing towards the camera). The line marked in blue is the horizontal angle it takes to reach the center, the up/down value is applied and then the horizontal angle is restored. this would work perfectly.
Do you know how I can get the specific angle to the horizontal center? Or is there an easier way to achieve this?
Answer by aditya-tfg · Aug 09, 2016 at 02:41 PM
Hi,
I am not sure if you are looking for this, but if you know your start and end vectors, you can get angle between them using Vector3.Angle(v3A, v3B). http://docs.unity3d.com/Documentation/ScriptReference/Vector3.Angle.html.