How do I manipulate offset CFrames in the world space?

A Motor6D’s transform is an offset value. How can I manipulate that in the world space?

For example: If I wanted to move the transform (offset) of a bone 5 studs in the world’s X axis how would I go about it?

Edit: Essentially giving Motor6D a WorldTransform property.

You can convert to world space by rearranging the CFrame equation:

1 Like

Thank you for this it’s an interesting read, however my situation is quite complex in my mind and I’m afraid I’m not exactly sure how to implement the solution into it.

This here is the desired result:

Here is the code for the rotation seen in the video:

           local MousePoint = UIS:GetMouseLocation()
			local TargetWorldToScreen = Camera:WorldToScreenPoint(ActionData.TargetOrigin.Position)
			local TargetPoint = Vector2.new(TargetWorldToScreen.X, TargetWorldToScreen.Y)

			local Property = ActionData.Property

			local a = ActionData.MouseOrigin - TargetPoint
			local b = MousePoint - TargetPoint

			local Angle = math.acos(a.unit:Dot(b.unit))

			local Res = Camera.ViewportSize

			local Intersecting = IsIntersecting(
				MousePoint, Vector2.new(Res.X,MousePoint.Y),
				ActionData.MouseOrigin + a * Res.X, ActionData.MouseOrigin - a * Res.X
			)

			local OverTheEdge = IsIntersecting(
				Vector2.new(Res.X, 0), Vector2.new(Res.X, Res.Y),
				ActionData.MouseOrigin + a * Res.X, ActionData.MouseOrigin - a * Res.X
			)

			local EdgeIntersect

			if OverTheEdge then
				local IntersectionPoint = FindLineIntersection2D(Vector2.new(Res.X, 0), Vector2.new(Res.X, Res.Y), ActionData.MouseOrigin + a * Res.X, ActionData.MouseOrigin - a * Res.X, true, true)

				local YMul = 1

				if TargetPoint.Y > ActionData.MouseOrigin.Y then
					YMul = -1
				end

				EdgeIntersect = IsIntersecting(
					MousePoint, Vector2.new(Res.X,MousePoint.Y),
					IntersectionPoint, Vector2.new(Res.X, Res.Y*YMul)
				)
			end

			if TargetPoint.Y > ActionData.MouseOrigin.Y then
				Angle *= -1
			end

			if not Intersecting and not EdgeIntersect then
				Angle *= -1
			end

			local TargetPointToWorld = Camera:ScreenPointToRay(TargetPoint.X,TargetPoint.Y,5)

			ActionData.Target[Property] = CFrame.fromAxisAngle(CFrame.new(TargetPointToWorld.Origin, ActionData.TargetOrigin.Position).LookVector,Angle).Rotation * ActionData.TargetOrigin
			ActionData.Target[Property] = CFrame.new(ActionData.TargetOrigin.Position) * ActionData.Target[Property].Rotation

Now using this code with Motor6D transforms it looks like this:

This is of course expected but I have very little idea as to how I should convert that code to function with transform values. I really appreciate it if you can help.

For anybody looking for a solution on a “WorldTransform”, where Part1’s CFrame would move to targetCF (in world coordinates):

motor.Transform = motor.C0:Inverse() * motor.Part0.CFrame:Inverse() * targetCF * motor.C1

This is derived from the following formula in [Live] Changes to Motor6D.Transform and Motor.CurrentAngle :

Part0.CFrame * C0 * Transform == Part1.CFrame * C1
1 Like