Hi. I’ve been struggling with this for a while now. I want my character’s arms to face the opposite direction of the camera. He’s supposed to aim wherever the camera looks, in third person. Preferably using LookAt(), because I (think) I understand how to use it. The problem though, is that the bones I want to rotate have really messed up axes. Both me and a friend tried to change the orientation of the bones local axes in Blender, but it seems that it is not possible. Here is a picture of how the right upper arm bone’s axes look:
As you can see, the z axes points up, when it should really point out of the arm. The +y axis points where -x should be and -x points where +z should point. When I use LookAt, I naturally get some weird results. If the axes where correct, I believe i would write the script something like this?
function LateUpdate () {
direction = Vector3(0,0,1);
direction = cameraTransform.TransformDirection(direction);
transform.LookAt(transform.position+direction);
}
I’m not at a computer where i can test this right now, so please correct me if i’m wrong.
This would take a forward direction and transform it so that it is the camera’s forward, and then apply it to the bone. Right? Well, this doesn’t work, as the axes are messed up. How should I go about making the bone rotate to always face the camera’s forward direction?
If I understand LookAt() correctly, it rotates the object’s z axis to the target specified, and then it rotates the object’s y axis to point in either world up direction, or the up direction specified. Is this correct?