Rotating the players body parts through script

Hey there. I don’t have access to any of the code I tried but I will do my best to explain. I’m trying to make a very detailed moving system that will make the players torso bend down more the faster they are running, there elbows bend more, and there legs reach further during the animation,

The reason for approaching it like this is that the movement I’m making is very acceleration based, the player has an acceleration speed and a speed cap, both of which are increased while holding shift to sprint, as in the player doesn’t just go from 0-100 when they start walking, it’s a subtle but noticeable increase.

Anyways, how I plan to go about it is using code to rotate and bend the players arms instead of an animation so that I’m able to change angles and such through code and have it automatically update with the players speed, similar with the torso, and the legs are a bit more detailed of an animation so I’m thinking I will have a subtle animation playing while its rotating through a script at the same time. Does that make sense? Kinda hard to put the thought in my head into words.

I’m still very confused as to how rotating body parts works, and every attempt I’ve made either doesn’t work and actually stops the player from animating at all, or rotates the whole body forward and nothing else, dealing with this kinda character scripting is new to me if you can’t tell…

I think I will do away with the built in animation script entirely and simple have an idle animation that stops when the player is moving. I already know how to do that part, just putting it here in case it effects anything.

Thank you!

2 Likes

Idk how this works can I bump?

You can always try…

  • Setting the motor6d using tan, etc…
  • Inverse kinematics

Hey thanks! Again this isn’t a field I’ve worked much in could you provide a link to some articles/tutorials or provide a code snippet of sorts?

For Inverse Kinematics, here it is

And while for setting the motor6d, it is rather more different as this is an example of when I used this to replicate the tds towers looking at mobs, where I used tan which is for angles. Now I don’t know if this is the best way to do this but this is how I did it.

Firstly, this is the formula
image
Link

I used this formula which in luau is math.atan(), after this I used math.deg to get the angles.

local TanT = math.deg(math.atan(RYCordDis/RDistance))

For RYCordDis, it is just the difference in Y so use the 2 part’s Y cord and minus.
For RDistance, you use the (Point1.Position - Point2.Position).Magnitude

I can’t directly add the angle to the motor6d so I multiplied the angle to it.

part["YourMotor6dName"].C0 *= CFrame.Angles(0,0, math.rad(TanT))

You may wanna check in the game and edit the motor6d yourself to see if you want to add it to the X, Y and Z coordinates in this case mine is Z to move the hands up or down.

After doing this, you should be able to change the hand angles without breaking anything :grin: