Animating / Moving part via Motor6D to a pre-defined path

Hello everyone. I personally have never used Motor6D’s before to animate so I require some help. I have a part which I want to follow a pre-defined path that has been made. Here is an example of what I mean (this was drawn in Microsoft Paint, so don’t expect high-quality drawings):

Now, I have animated parts and models many times before this way, but I have used TweenService. Although I would love to use TweenService, I am going to be using a Motor6D since the part will be on a moving object and therefore will not be anchored and the location of the moving object will not be fixed. What I want is the Part1 to move to Part2 and from there move to Part3. The movement should look like this:

I have seen tutorials use the C1 of the Motor6D and just multiply C1 by a small CFrame value in a for loop, and although that does work, you have to make small adjustments here and there until it is perfect, and I do not really want that. What I want is to be able to do something similar to TweenService where you just need to have a pre-defined path, and from there, you specify how long you want it to take and it will move from one point to the other in that amount of time. Keep in mind that I am using a Motor6D, so this will have to be Motor6D friendly.

I do apologize if I explained this badly. I have looked for multiple tutorials trying to figure out how Motor6Ds work and how to animate but none of them did a really great job at explaining how to use them and how I could make an efficient system like this, most animating tutorials used for loops and are decently old.

The ideal thing would be if there could be a function such as MoveParts(motor6D, locationPart, timeToMove) which takes in motor6D which is a Motor6D, locationPart which is the part that Part1 of the motor6D will be moving to (will most likely multiply C1 with another CFrame value that will move it to that position), and timeToMove which will be a number of the time that it will take to move. timeToMove is not a requirement as it can easily be implemented later with some calculations, but I have never used Motor6Ds or Welds so I am not too sure how it works and how I can make such system work. If you could help me, that would be amazing. Thank you for your time and effort. Please let me know if you need some more information, have any questions, or need me to clarify something. Again, thank you for your time and effort, I greatly appreciate it.

Hey @Batimius,
I’m assuming that Parts 2 and 3 will remain in the same position relative to the Door? (as in they are welded to the Door Part) If that’s not the case, this is a bit more complex of a problem, but still doable! Fill in that detail for me and then I can help more!

Thank you for the reply. Yes, the parts will stay relative to the door (or vehicle in this case). Here is an example picture:

Basically, everything inside the brown pad will be moving relative to it, so in our case, everything is relative to the brown part (you can ignore the door for now). All the parts in the brown area will move as one, Part1 will just be moving between Part2, Part3, and it’s original position (I already have a part there, but I didn’t include it so I would not create more confusion). Again, thank you for the reply, I greatly appreciate it.

Cool, so you actually wouldn’t need to use a Motor6D as just a simple Weld would get the same end result, but either is fine. Also, you can still use the TweenService! What you’re going to want to do is figure out the offset from the Door Part to both Parts 2 and 3. You can also figure this out in code with a line like:

local p2Offset = Door.CFrame:PointToObjectSpace(Part2.Position)

Now, assuming that Part1 is initially welded at the center of the Door, you can use a Tween created on the C0 property of your Weld or Motor6D and with destination of p2Offset. Wait for that Tween to finish, then repeat the process with Part3’s Position used in the offset calculation. The next tween will now move the Part from Part2’s relative position to Part3’s relative position! Lmk if that helps or if theres any parts youre stuck on

1 Like

Use Motor6D.Transform instead of Motor6D.C0 or C1

Thank you very much for the reply. I did try using TweenService but it did not work as expected. Here is the code that I used:

local TweenInformation = TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
local Tween = TweenService:Create(Motor, TweenInformation, {C1 = Path["Path1"].CFrame})
Tween:Play()

If I am correct, would I replace {C1 = . . .} with {C1 = C1:PointToObjectSpace(Path["Path1"].Position)}, or would I need to do something different? I apologize for not understand and basically requesting to be spoon-fed, I am just brand new to the concept of Welds and Motor6D’s. Thank you for all the help, truly appreciate it.

Thank you for the reply. I am brand new to Motor6Ds, so in this case, how exactly would I use that function to achieve my goal? Again, thank you for the reply.

Keep in mind you have to known some CFrame magic.

I think lerping and beziers curves could be applied to your use case.

1 Like

Thank you for the reply. I do not really know CFrame magic, that is probably the reason that I am making this post in the first place. I always used TweenService to animate models and such and never really used Motor6Ds or Welds, so I never had to do such stuff. When it comes to this stuff, I basically have very little idea on what I am doing, so the link to the article does not help me as much, I will though try to read it and see what I can understand.

Here, I coded up a little example that I tried to make similar to your situation. Check out its code and see if it can’t help you. I am still using the C0 property.
AnimationWithMotor6D_Transform.rbxl (22.9 KB)

1 Like

Thank you for the reply and the demo. You are a life saver! Not only did it help me achieve my goal, but it also allowed me to understand how it works and that knowledge will come in useful in the future as well. Thank you so much! You are a legit life saver!