Motor6D C1 Spinning

When I try to set the Motor6D of a part on the character for a gun system, it starts randomly spinning. The speed of this spin is correlated to the angle I give it in CFrame.Angles

Code:

local motor6d = Instance.new("Motor6D")

motor6d.Part0 = character:WaitForChild("RightHand")
motor6d.Part1 = handle

motor6d.C1 = CFrame.new((-character.Head.CFrame.LookVector.Unit * 0.7)) * CFrame.Angles(0, math.rad(-90), 0)

motor6d.Parent = model.PrimaryPart

Result:

This has never happened to me before so I hope you can understand my confusion

2 Likes

Are you sure that’s the exact code which causes this and that you didn’t leave anything out?

1 Like

Yep

chhhhhaaaaaaaaaaarrrrrrrrrsssssssssss

Interesting, I’m just a bit confused as how that would be the case. Usually when a character turns into a perpetual motion machine, it’s because a Motor6D’s CFrame is being set inside some kind of loop incorrectly. From that code, it appears you just set it once?

Furthermore, if that’s the case, does the character’s arm still spin if you disable the default animation script inside of the character? The goal of disabling the Animate script is to isolate the problem and make sure the problem occurs on its own, without animations being active on the character’s rig.

Yeah, I even used a print statement before it sets the C1 to see if its caught in a loop but no.

Its incredibly strange behavior.

I think it might be something to do with the fact I am using IKControls. I disabled them and it works fine.

No, not really, think of it like a dog chasing their tail; the dog is never getting closer to their tail which each spin. This behavior is expected when you setup the IK incorrectly.

What was incorrect about the IK setup?

The IK Target, (the gun’s handle part), was rigidly attached to a body part somewhere between the ChainRoot and the EndEffector, so when the character’s hand moved, so did the Target. This means the IK made zero progress towards its goal with every IK iteration, resulting in a perpetual motion machine.

Yep, I already fixed it myself

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.