Building a Hinged Platform
Building a Hinged Platform
In the Making Your Own Obby Game tutorial, you learned the basics of using Roblox Studio and you designed a basic obby. In this tutorial, we’ll expand on what you learned to create an obstacle that players must overcome: a tilting, see-sawing platform.
Creating the Support and Platform
The hinged platform will tip back and forth as the player walks on it, but first it needs a solid support to attach to (otherwise it will just fall down into space).
Create the Support
Our support can be a simple cylinder, anchored in place.
- Somewhere near another platform in your obby, create a small Cylinder part.
- Anchor the new part in space.
Create the Platform
Next, create the platform that will tip back and forth. Make sure it’s centered left-to-right with the support part so that it balances.
Remember that you might need to adjust the snap amount to get the platform to align exactly next to the support part.
Name the Parts
As you design bigger and better games, it’s a good idea to enter custom names for important parts. This helps you find those parts in the Explorer window when you need to change something about them.
- In the visual game editor window, find and select the platform support part that you created. In the Explorer window, that part will be highlighted.
- Notice that most parts are just named “Part” — that’s not too helpful, so let’s change it. Right-click on the part name in the Explorer window to show a menu of options, then select Rename.
- Type in PlatformSupport, a much better name for this part.
- Next, back in the game editor window, find and select the platform part itself. In the Explorer window, right-click on the part’s name and select Rename, just like you did for the support part. For this part name, type in HingePlatform.
Attaching the Parts
Now that you have two parts for the hinged platform, it’s time to attach them. In Roblox, one way to attach a part to another part is with a constraint. Constraints attach two parts together and let you create special behaviors for the parts.
Here are some examples of constraints in real life:
|Door hinge||The door and the wall|
|Axle on a bike wheel||The wheel and the bike frame|
|Boat propeller shaft||The boat engine and the propeller|
|Your knee||Your upper leg and lower leg|
For this hinged platform, we’ll attach it to the support part with a Hinge constraint.
- To get a better view of things before you add the constraint, move the platform away from the support by a few studs.
Select the platform support part in the game editor window or select it from the Explorer window (notice that it’s easier to find since you changed its name to PlatformSupport).
Zoom in to get a better view of the part. Remember that you can also focus on the part by pressing the F key.
Make sure that you’re viewing the Model tab.
- In the Constraints section, click the small arrow below Create and select Hinge.
- Move your mouse pointer into the game editor window and hover over the support part. You will see a small, bright green object called an Attachment — this tells Roblox exactly where to connect the start of the constraint. Carefully move your mouse over the side of the part until the attachment is centered, then click to add it.
- Adjust the camera view so that you can see the thin side of the platform (HingePlatform) located near the support part.
- Move your mouse pointer over the side of the platform. You’ll see a second bright green attachment which tells Roblox where to connect the end of the constraint. Carefully move the mouse until the second attachment is positioned across from the first attachment, then click to add it.
Great job! The red line that connects the two green attachment objects shows the new hinge constraint.
Changing the Weight
Imagine if this platform existed in real life and it was even bigger than you. If it was made from solid metal and you put an apple on one end, it probably wouldn’t move much. Why? Because the apple doesn’t weigh very much compared to the heavy metal platform.
Now imagine if the same platform was made from cardboard, like an empty box — if you put an apple on one end, it would probably tip down because the apple’s weight is enough to move the light cardboard platform.
For your obby, consider the same thing. When a player jumps onto one side, will the platform move so easily that the player is quickly dumped off into empty space? Or will the platform move so slowly that players can just stand on it like a normal anchored platform?
Set the Density
In Roblox, a part’s weight is automatically assigned based on its size (bigger objects will always weigh more than smaller objects). For this hinged platform, however, we need to change its weight to something different.
- Select the platform part in the game editor window or select it from the Explorer window.
- Open the Properties window by selecting the View tab and clicking the Properties button.
- Find the Part section and look for a row named CustomPhysicalProperties (you may need to expand the Part section by clicking the small arrow next to its name).
- Click the small checkbox inside the row.
- For Density, type in a higher value like 5.
Time to test the hinged platform and see how it works!
- Press the Play button:
- Run and jump over to where you put this obstacle. When you jump onto it, the platform should tip back and forth like a see-saw. Your goal is to balance and move across it without being tipped off into empty space.
Great job! Now your game has a cool new obstacle which challenges players to balance with greater control.