Look at with CFrame while accounting for the player's rootpart orientation

Hi, I’m making a really simple system emulating inverse kinematics meant for vehicles in my game (say, a player is riding a bike rather than a car. Rather than making new animations, I just want to make it easy and make points to move the player’s legs.)

I think I have it down, it’s as simple as using CFrame.LookAt, which I understand very well. My only issue is that I’m using this on Bones, rather than the player’s root. It works, but not the way I wanted it to. I want the legs to always “look at” the vector where the legs should be, no matter the player’s orientation. I got really close to this once, but the player would keep their original leg orientation at a certain angle.

You know that old flashlight tool that would have the player’s arms point at the mouse’s hit position? I’m looking for something like that.

1 Like

Sorry, is this for R6 or for R15? Also, what did you mean by this what is this certain angle and why is it not desirable? Hard to see what you mean by this statement by itself.

Anyways when dealing with legs I believe the leg parts of the model have the longer side of the part be the look vector as seen in the diagram below:

So if you are using CFrame.lookAt the leg bottom face won’t exactly be facing the pedal. I believe this is the problem you are talking about? You can easily offset this though by adding an additional CFrame rotation on the X axis by 90 degrees so the bottom face of the leg will be the new lookVector and the front face of the leg will be the new upvector:

leg.CFrame = leg.CFrame *CFrame.Angles(math.rad(90),0,0)