Moving R15 joints via script?

I’m trying to move the joints of a character. Basically I’m trying to animate a frisbee throw, but the motion is determined by the player, and thus I can’t just use an animation.

How would I go about doing this? I tried messing with the Motor6Ds and the Attachments, but couldn’t get them to do anything at all.

Attachments won’t change the way the player is animated, I would suggest looking into using Motor6D.Transform.

You can access 3 writable properties of Motor6D at runtime: C0, Transform, C1. That said, it matters very much when you set these. If you have any animations running on the character, you also have to be deliberate about whether or not you want your value from script to add to or overwrite what an animation might be doing to the same joints.

I would encourage you to figure out exactly when and how you want to alter a joint by taking a default-pose character (can be a copy of your character copy pasted from play solo into Workspace) and experiment with one joint, both printing out the values of C0, Transform, and C1 and setting them. Depending on what you’re trying to do, you might want to set one with a specific value, or you might want to multiply it by some incremental change.

The important thing is that you should repeat your experiment on both Renderstepped and Stepped, and note the important differences. It’s been a while since I played with this, and things may have changed, but I recall having the best luck manipulating Transform on Stepped, in order to be able to see and modify values set by a playing animation. I recall Heartbeat not being a viable option, I saw issues with missing updates on frames where Heartbeat wasn’t keeping up with Renderstep.

You can manipulate C0 and C1 also, but because these usually have translations, it can be more difficult to work out the values you need if what you’re doing is a simple rotation or translation. When parent Part A is connected to child Part B by a Motor6D, The orientation of Part B ends up being the orientation of Part A * C0 * Transform * C1:inverse(). Normally, Transform is the identity CFrame unless an animation is manipulating the joint, in which case the Transform value comes from the keyframe CFrame of the animation (or an interpolated value between 2 keyframes’ CFrames)

Either way, playing with these values directly takes a very good understanding of CFrames. You will need to do a lot of CFrame multiplication and inversion to do all but the simplest local-space adjustments to a joint.

7 Likes

Thanks for the detailed response! I’ll try experimenting with this and see what I can do.

1 Like