- Home /
Bone look at.
Is it posibble to make bone look at something, there's transform.SetLookAt which makes character's head look at something, is it posibble to do it with some other bone ? I really need this !
There tons of things in it, any other simple way of doing this ? And i won't give my money for it.
Is there any reason you can't just do that-- bone.transform.LookAt for another bone?
Nope, it just won't work. $$anonymous$$aybe becouse it's busy with the animation ?
Answer by Benjames · Mar 28, 2015 at 03:55 PM
So if you have a LateUpdate() function and put bone.transform.LookAt(position); in it so its effected after the animation.Then if it doesn't line up correctly you can always put something line this *
bone.transform.rotation=bone.transform.rotation * AngleAxis(90,Vector3.Up);
or
bone.transform.rotation=bone.transform.rotation * AngleAxis(90,Vector3.Left);
to rotate the bone on an axis.
This is what I used to get my character to point his gun at the aimers position correctly.
I spent a long time messing with this a while back to no avail. Then I did a little research on Quaternion rotations, watched a couple videos and what not. It really helped because I came back to this and got it working in $$anonymous$$utes.
This is basically "how do you LookAt using something besides the Z axis?" The way is to find the difference between the LookAt you want, and your +z; do the LookAt; then adjust.
The adjustment is a rotation, so is a Quaternion. Can get it using Quat.Euler, or AngleAxis, or can make an empty pointing the correct way and take the inverse of the localRotation ... . Probably more ways.
$$anonymous$$ost non-bone solutions just use parenting to make +Z be the way you want to look.
Ehh thanks i guess but this is kinda old, found a solution long time ago. It could sure help other people.
Can't test if it works so i can't give you a right answer tick
Thats fine, I was just saying that you can adjust the rotation after using LookAt(); to make the bone face the right direction.