How to make the piston move only on the y axis?

I am trying to make a simple engine simulation in roblox, and I need the crankshaft to be interconnected with the piston, so that the head only moves up and down and the rod adjusts to it. I have a reference image and a video to make you understand better

1 Like

Use Constraints.
Use a PrismaticConstraint for the piston movement. This aligns it like the cylinder bore would.
Use a HingeConstraint for the crankshaft rotation with it set to Motor.
Use 2 HingeConstraints at the ends of the connecting rod with their mode set to None.
Just like the way an actual engine works.

I’ve used the same setup in my Boat Obby!!! game to drive a spike at the boats to knock them off the path. It’s pretty large so you can see how it’s working when you play the game. It’s only level 4 or 5 so you wouldn’t have to spend a lot of time there.

1 Like

alright, I’ll try to somehow work it out. I already tried lots of constraints, but forgot about prismatic ones so I hope that works. Thanks for answering

1 Like

I am currently attempting to do it, but I don’t know how to set up the prismatic constraint. I could use some help

1 Like

Click the Constraints tool in Studio.
Select the Prismatic.
Select the piston with the mouse, then select something that’s Anchored.
Make sure both the Attachments yellow arrows and orange arrows point the same way.
Make sure they are in a straight line (the Green line of the Prismatic)
The piston should now slide along the green line.

I’m not sure if I understood, but the piston still isn’t moving. I will send how the engine acts when I crank the starter, and I will remove the wall (anchored part) to show that it spins the crankshaft.

Ohhhh, I figured it out. I had interconnected the rod with the bearing using hinges, and not the bearing with the crankshaft. Now I did the opposite and it works like a charm. Thank you for responding, you are a life saver!

No worries.
Also, try the View Constraints tool in the Model tab. It’ll show you all your constraints without having to click on each one.

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