GSmGpE6CwX2y9JjB25B8
We use cookies on this site to enhance your user experience

Building a Turning Platform

Building a Turning Platform

Sep 06 2019, 3:29 PM PST 10 min

In the articles/Creating Your First Game|Making a Basic Platformer tutorial, you designed a basic obstacle course. In this tutorial, you’ll create a turning platform that makes players jump with perfect timing to land safely on it.

Creating the Base and Platform

The turning platform will spin around and around like a clock hand, but first it needs an anchored “base” or it will fall down into space.

Create the Base

The base can be a simple block, anchored in place.

  1. Somewhere near another platform (but not too close), create a small block.
  1. Anchor the new part in space.

Create the Platform

Next, create the platform that will eventually spin around and around. Position this platform so that it sits on top of the base you just created.

Name the Parts

As always, it’s a good idea to name these new objects so they’re easy to find in the Explorer window.

  1. In the game editor window, select the platform base that you created.
  2. In the Explorer window, right-click the part’s name and select Rename.
  3. Enter in PlatformBase.
  1. Back in the game editor window, find and select the platform part itself. In the Explorer window, rename the part to TurnPlatform.

Attaching the Parts

The basic platform setup is done, but there’s nothing special about it yet. In fact, if you run the game now, the platform will probably just fall off the base and down into space. To prevent that, you need to attach the platform to the base with a constraint.

  1. To get a better view of things before you add the constraint, move the platform directly up a few studs.
  1. Select the PlatformBase part in the game editor window, or select it from the Explorer window.
  2. Zoom in to get a better view of the part. Remember that you can also focus on the part by pressing the F key.
  3. Make sure that you’re viewing the Model tab.
  4. In the Constraints section, click the small arrow below Create and select Hinge.
  1. Move your mouse pointer into the game editor window and hover over the base part. Move your mouse over the part until the attachment (green sphere) is centered on the top surface.
  1. Click the mouse button to add it.
  2. Adjust the camera view so that you can see the bottom of the platform (TurnPlatform) located above the base part.
  1. Carefully move the mouse over the bottom of the platform until the second attachment is positioned directly above the first attachment, then click the mouse button to add it.

Making it Spin

In the Explorer window, find and expand the branches for both PlatformBase and TurnPlatform. Highlighted here are the new constraint objects:

Object Description
Attachment0 The first attachment you added, connected to the top of the PlatformBase part.
HingeConstraint The actual hinge constraint.
Attachment1 The second attachment you added, connected to the bottom of the TurnPlatform part.

At this point, the turning platform can spin around the hinge axis but there’s no power to drive it. Fortunately, a hinge can also be made into a motor that turns the platform.

  1. In the Explorer window, select the HingeConstraint object that attaches the platform to the base.
  1. In the Properties window, browse all of the properties for the HingeConstraint object. Locate ActuatorType, an important property that makes a basic hinge into a powered motor.
  1. For this ActuatorType property, click in the area to its right and select Motor.
  1. Now look at the Motor properties which appear slightly below. To make the platform turn, type in a new value for AngularVelocity. This value determines how fast the motor should turn — in this case, a value of 0.5 should be fine.
  1. Finally, change the value of MotorMaxTorque to 10000. In your future game design, this value may need to be even higher for a motor to turn a very large, heavy part.

Finishing Up

To finish up, move the turning platform back down so that it sits on the PlatformBase part.

Now press the Play button to test. If you did everything right, the turning platform should slowly spin around on the base. The player’s challenge is to jump on the platform at the correct time, then let it carry them around until they can safely jump off to another platform.


Now your game has a dynamic obstacle which challenges players to jump and move with greater skill. Where next? Check out the tutorials below which can help push your game to an even higher level!

Tags:
  • basics
  • studio
  • obby
  • constraints