How do I move a Motor6D C0 in world space?

I know that Motor6D are just offsets, so they are pretty much in local space; but I am trying to move it in world space

This is the code I tried which I thought would work but to no avail, it was supposed to move the Neck Motor6D on the global Z axis but instead it’s moving it on the X global axis

workspace.TemplateR15.Head.Neck.C0 = workspace.TemplateR15.Head.Neck.C0:ToWorldSpace(CFrame.new(0,0,1))

It’s crazy to me that this is one of the only threads about trying to move a C0 in world space, but well… I’ll be the first to solve it then

So as I said above, the Motor6D C0 is just really an offset from Part0 so this means that it is in local space, we have to basically convert it to world space and apply the transform we want!

So for example here, we convert the Motor6D C0 to world space

local A = motor.Part0.CFrame:ToWorldSpace(CFrame.new(motor.C0.Position)) 

Now we can add the translation we want, so lets say we want to move forward on the global Z axis, we can do this

A = A + Vector3.new(0,0,1)

So now we’ve added the translation we have too convert A back to local space

We would do that like this

local B = motor.Part0.CFrame:ToObjectSpace(A)

Now that we have our translated world space in local space, we can apply it directly to the Motor6D’s C0

motor.C0 = B

And that’s all there is too it, thanks!

3378e046c6ddc95ccb9dd2344abaf0bb040b3f0f

1 Like

Couldn’t you just convert the desired world space movement vector to local space and add it to Motor6D.C0.?

Motor6D.C0 += Motor6D.Part0.CFrame:VectorToObjectSpace(desiredWorldSpaceMovement)

The above is equivalent to the following:

Motor6D.C0 += Motor6D.Part0.CFrame.Rotation:Inverse() * desiredWorldSpaceMovement

In your code you do the following:

  1. Motor6D CFrame: local → world
  2. apply movement
  3. Motor6D CFrame: world-> local

The code I suggest only does the following:

  1. movement: world → local
  2. apply movement

With Motor6D CFrame I mean the CFrame whose position is the point around which the parts rotate and whose rotation defines the rotation axes. This CFrame is equal to Motor6D.Part0.CFrame * Motor6D.C0 and Motor6D.Part1.CFrame * Motor6D.C1.

1 Like

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