In Physics Part 1, we started building a pinball game by using Amazon Sumerian physics. When we pressed play, the ball moved around and eventually fell off the pinball Table in a physically realistic way.
In Part 2, we’ll enhance the scene by adding controls and Flippers using a custom script to create a functional game.
You’ll learn about:
- Rigid Body component
- Collider component
- State Machine
Before you begin, you should have completed the following tasks and tutorials:
- Sign in to Amazon Sumerian with your AWS account
- Amazon Sumerian Interface tutorial
- Sumerian Basics: Creating a TV Room
- Scripting Basics tutorial
- Material Fundamentals tutorial
- Nesting Using a Solar System tutorial
- Physics Part 1
Step 1: Reset the Table Tilt
We’ll add two more Bumpers, the bottom Flippers, and Slants. Then we’ll use a script to create the appropriate behavior. But before we can add new entities to the Table, we have to reset the Table tilt.
The Table’s X Rotation is currently set to 36. Reset it to 0. To see these values, select the Table in the Entities panel, and expand the Transform component in the Inspector panel.
Step 2: Add Two More Bumpers
There are currently three Bumpers and we want to add two more.
Duplicate Bumper1 two more times (using the Duplicate button at the top of the Entities panel) to create Bumper4 and Bumper5.
With the new Bumpers selected, use the Translation gizmo to move them. Be sure you have the Translation gizmo selected in the upper right of the canvas.
Drag the new Bumpers to different locations on the Table. However, don’t change the Y Translation, because this will lift the Bumpers off the table.
Step 3: Add Slants
Now we add the Slants. These are at the sides of the Flippers and keep the ball from falling out the bottom.
From the Create Entity menu, add two more Boxes, and then rename them “LeftSlant” and “RightSlant”.
Change the Transform values for the LeftSlant and RightSlant to the following.
Add a Collider component to both LeftSlant and RightSlant with the following settings.
Your table should look something like this.
Step 4: Add Flippers
The Flippers need to hinge on one side. To get this effect, we need to provide an anchor so the entities will hinge instead of spin. We use an Empty parent entity as the anchor.
Add two Empty entities from the Create Entity menu.
Rename the empty entities “LeftFlipperPivot” and “RightFlipperPivot”.
Change the Transform values of the LeftFlipperPivot to the following: Translation (-7.825, 1.5, 13.5) and Rotation (0, -23, 0).
Change the Transform values of the RightFlipperPivot to the following: Translation (7.825, 1.5, 13.5) and Rotation (0, 23, 0).
Give them each a Rigid Body component and check the Kinematic checkbox.
To add the Flippers themselves, add another two Boxes. Name them “LeftFlipper” and “RightFlipper”.
In the Entities panel, nest the left and right Flippers under their respective Pivot entity by dragging and dropping the Flippers onto the Pivot entities.
Nest the both the LeftFlipperPivot and RightFlipperPivot entities under the Table entity by dragging-and-dropping them onto the Table entity. Here is the final entity hierarchy in the Entities panel.
Change the LeftFlipper Transform values to the following: Translation (3.5, 0, 0.5) and Scale (7, 2, 1).