# Need help with rotating a skeletal mesh bone so that it is facing a certain direction

So i have been trying to make it so that my AI can look around at various objects in the world but i have gotten stuck trying to rotate the head bone of the skeletal mesh to the rotation which points at the object. The issue i’m having is that when i try to rotate the bone using the Transform (Modify) Bone the various, pitch, yaw and roll values affect things they should not. Also when putting in a zero rotator the head does not look straight forward. I’m not really sure what i’m doing wrong and this feels like it has a simple solution. I’m using the pre 4.8 skeletal mesh that was included in the third person template.

I will try to explain what is happening.
This is the animation blueprint when i put in (0.0, 0.0, 0.0).

And these are some other values to show how the head rotates.

(90.0, 0.0, 0.0) http://i.imgur.com/QOk5CRt.png

(0.0, 90.0, 0.0) http://i.imgur.com/BzSK1E8.png

(0.0, 0.0, 90.0) http://i.imgur.com/FcTmby3.png

(90.0, 45.0, 0.0) http://i.imgur.com/XbF9fAj.png

(90.0, 0.0, 45.0) http://i.imgur.com/R6kz3KQ.png

Can anyone explain why the rotations are so weird or how i could fix it? I can’t for the life of me figure out how to make the head rotate to look at objects when these rotations act like they do.

Edit:

Still haven’t figured out how to make the AI correctly rotate it’s head.
This is the code that creates the rotation that is used to rotate the head. MostInterestingPoint is the location that the AI should look at.

``````if (!MostInterestingPoint.IsZero())
{
FVector TempVec = MostInterestingPoint - ControlledPawn->GetMesh()->GetSocketLocation("headSocket");
LookAtRotation = FRotationMatrix::MakeFromX(TempVec).Rotator();
}
``````

Any help would be greatly appreciated as i cannot figure out how i should do it.