Build OrbitRun with Smart Shape | Part 2: Control the flight
Your ship is moving, but you can’t control it yet. Give it a stronger downward pull while you hold the screen, then ease that pull when you let go. Once the flight feels right, add a distance score and a 90-second countdown.
Start with your project from Part 1, or open OrbitRun-05-launch.tap from the checkpoint pack. All behaviors below belong to Skimmer. Keep each numbered lesson in its own commented area, with space between rows and columns.
In the diagrams, REUSE means use the behavior you already added. For a reminder of the gestures, see connecting behaviors in Part 1. You can tap an image to open it at full size.
6. Hold to dive; release to glide
Press as the ship heads downhill. The extra gravity helps it gain speed. Release where the hill turns upward, and that speed carries it into a climb.
First, make a press change gravity while a run is active.
Open the completed diagram as a still image.
- Add While Touching named Touch.
- Add Get Attribute named Touch State. Connect a free bottom white circle on Touch to Touch State.
- Add If named Touch Running. Connect a free bottom white circle on Touch State to Touch Running.
- Add Set Gravity named Dive. Connect Touch Running’s bottom (true) circle to Dive.
- Add Change Label named Dive Cue. Connect Touch Running’s bottom (true) circle to Dive Cue.
Use these settings:
- Touch: Input Plane; Touch Anywhere Off; Absorbs Touch On. Leave it listening from scene start.
- Touch State: Skimmer; attribute
runState. - Touch Running: first value from Touch State’s Attribute Value; Equals; second value
running. - Dive: Skimmer; gravity type Object; X 0, Y −32.
- Dive Cue: Cue; text
DIVING / RELEASE AS THE HILL TURNS UP.
Both Dive and Dive Cue connect directly to Touch Running’s bottom connectors. Leave its right-side false connector unused.
Drag the state into If
After you drop it, First value (A) contains Touch State · attributeValue. Set comparison to Equals; second value: running.
Letting go should restore the lighter gravity. Reuse Release from Part 1.
Open the completed diagram as a still image.
- Add Stopped Touching named Touch Ended.
- Add Get Attribute named Release State. Connect a free bottom white circle on Touch Ended to Release State.
- Add If named Release Running. Connect a free bottom white circle on Release State to Release Running.
- Reuse Release. Connect Release Running’s bottom (true) circle to Release.
- Reuse Glide Cue. Keep its existing execution connection from Release; the animation redraws that wire for reference. Do not add a second connection.
Use these settings: Touch Ended targets Input Plane, with Touch Anywhere Off, Absorbs Touch On, and Check Boundaries Off. Release State reads Skimmer’s runState. Release Running compares that Attribute Value to running.
Move the existing Release and Glide Cue below Release Running. Keep their existing connection and their earlier launch connection. Release still sets object gravity to X 0, Y −12; Glide Cue still displays the gliding instruction.
Launch and hold on the open play area, then lift your finger. Cue should alternate between DIVING and GLIDING. Check this away from the music button. Holding on the title screen should not start a dive.
If touch does nothing, check that Input Plane is on Scene UI, behind the buttons, covering the screen, and visible with 0% opacity. If releasing outside its original touch point fails, check Check Boundaries Off.
Both touch checks read runState before changing gravity. They allow a dive only when its value is running. The same checks will keep the ship still after you add an ending.
7. Point the ship along its velocity
Your ship should point down as it falls and up as it climbs. Start a repeating timer to read its velocity. You’ll use that same reading to help it recover from a slow landing.
Read velocity before checking either speed limit. Both checks start from Velocity.
Open the completed diagram as a still image.
- Reuse Generate.
- Add Timer named Flight Tick. Connect a free bottom white circle on Generate to Flight Tick.
- Add Get Velocity named Velocity. Connect a free bottom white circle on Flight Tick to Velocity.
- Add If named Slow Check. Connect a free bottom white circle on Velocity to Slow Check.
- Add If named Fast Check. Connect a free bottom white circle on Velocity to Fast Check.
- Add Set Velocity named Assist. Connect Slow Check’s bottom (true) circle to Assist.
- Add Set Velocity named Speed Limit. Connect Fast Check’s bottom (true) circle to Speed Limit.
Use these settings:
- Flight Tick: 0.05 seconds, Repeat Forever On, Start Immediately Off. Generate’s trigger remains Ready.
- Velocity: target Skimmer.
- Slow Check: Velocity’s X Velocity < 8. Assist: X 12, Maintain X Off, Maintain Y On.
- Fast Check: Velocity’s X Velocity > 42. Speed Limit: X 42, Maintain X Off, Maintain Y On.
The checks sit above their effects. Slow Check and Fast Check are separate children of Velocity.
Drag X velocity into the check
After you drop it, First value (A) contains Velocity · velocity_x. Set comparison to Is Less Than; second value: 8.
Here is the same drag in the real editor. Select Slow Check first. Drag Velocity’s green output icon into the first input and choose velocity_x.
See Sharing Values Between Behaviors and If. The green button inside an input field creates a Change Input Field behavior; use the output icon on the source behavior for this drag.
Use the same velocity reading to calculate the ship’s angle.
Open the completed diagram as a still image.
- Reuse Velocity.
- Add If named Angle Moving. Connect a free bottom white circle on Velocity to Angle Moving.
- Add Divide Values named Slope Ratio. Connect Angle Moving’s bottom (true) circle to Slope Ratio.
- Add Math Function named Flight Angle. Connect a free bottom white circle on Slope Ratio to Flight Angle.
- Add Multiply Values named Clockwise Angle. Connect a free bottom white circle on Flight Angle to Clockwise Angle.
- Add Rotate To Angle named Rotate. Connect a free bottom white circle on Clockwise Angle to Rotate.
Use these settings:
- Angle Moving: Velocity’s X Velocity > 0.1.
- Slope Ratio: first number = Velocity’s Y Velocity; second number = Velocity’s X Velocity.
- Flight Angle: Arctangent, taking Slope Ratio’s result.
- Clockwise Angle: first number = Flight Angle’s result; second number = −1.
- Rotate: target Skimmer; angle = Clockwise Angle’s result. Use a short duration for a smooth turn.
Use the green output drag for each referenced number. Do not type a formula into a number field. Use the behaviors to calculate it, then place their results into the receiving fields.
Play without touching for a few hills. The ship should turn nose-down on descents and nose-up on climbs. It should keep moving after slowing down.
The angle comes from atan(vy / vx). Checking X velocity first keeps the division away from zero. Multiplying by −1 turns the result in the direction hyperPad uses for rotation.
This calculation assumes your ship moves forward. If you adapt it for backward flight, you’ll also need to account for direction, using atan2 or separate checks for each quadrant.
The assist and cap change only horizontal velocity. Maintaining Y preserves the current jump or fall. The 42 value is an X-velocity cap, so the total speed displayed later can exceed 42 during a steep dive.
8. Turn world position into a score
Your score measures how far the ship has traveled horizontally. Subtract its starting X position from its current world X. The camera can move as much as it likes.
This connection reads the ship’s position and turns it into the distance label.
Open the completed diagram as a still image.
- Reuse Generate.
- Add Timer named Hud Tick. Connect a free bottom white circle on Generate to Hud Tick.
- Add Get Position named Position. Connect a free bottom white circle on Hud Tick to Position.
- Add Subtract Values named Distance Value. Connect a free bottom white circle on Position to Distance Value.
- Add Round Number named Distance Round. Connect a free bottom white circle on Distance Value to Distance Round.
- Add Combine Text named Distance Text. Connect a free bottom white circle on Distance Round to Distance Text.
- Add Change Label named Distance Label. Connect a free bottom white circle on Distance Text to Distance Label.
Use these settings:
- Hud Tick: 0.2 seconds; Repeat Forever On; Start Immediately Off.
- Position: Skimmer; Screen Coordinates Off.
- Distance Value: first number = Position’s X Position; second number = 8.
- Distance Round: Distance Value’s result; mode Floor.
- Distance Text: first input = Distance Round’s result; second input =
m; Space On. - Distance Label: target Distance; text = Distance Text’s Combined Text.
Use world X in the calculation
After you drop it, First number (A) contains Position · position_x. Keep the second number at 8: current X minus start X.
Add the speed display to Hud Tick as a separate connection.
Open the completed diagram as a still image.
- Reuse Hud Tick.
- Add Round Number named Speed Round. Connect a free bottom white circle on Hud Tick to Speed Round.
- Add Combine Text named Speed Text. Connect a free bottom white circle on Speed Round to Speed Text.
- Add Change Label named Speed Label. Connect a free bottom white circle on Speed Text to Speed Label.
Use these settings: Speed Round reads Velocity’s Speed output and uses Floor. Speed Text combines Speed Round’s result with m/s, Space On. Speed Label targets Speed and reads Speed Text’s Combined Text.
Drag Velocity’s data into Speed Round’s number field. The execution connection comes from Hud Tick, as the diagram shows. Reading Velocity’s value does not require an execution wire from Velocity to Speed Round.
Launch and watch Distance rise from near zero. At world X 108 m, the displayed distance should be 100 m because the ship started at X 8 m. Camera movement should not reset the score.
Hud Tick reads the latest result from Velocity. It updates the labels five times a second while the flight checks run more often. You can slow a display update without slowing the ship’s physics.
The Set Label reference describes the label-change behavior (labeled Change Label in this editor).
9. Count down from 90 seconds
Start the seconds timer from Ready, just like the other timers.
Open the completed diagram as a still image.
- Reuse Generate.
- Add Timer named Seconds Tick. Connect a free bottom white circle on Generate to Seconds Tick.
- Add Add Values named Seconds. Connect a free bottom white circle on Seconds Tick to Seconds.
- Add Subtract Values named Remaining. Connect a free bottom white circle on Seconds to Remaining.
- Add Combine Text named Clock Text. Connect a free bottom white circle on Remaining to Clock Text.
- Add Change Label named Clock Label. Connect a free bottom white circle on Clock Text to Clock Label.
Use these settings: Seconds Tick uses 1 second, Repeat Forever On, Start Immediately Off. Seconds adds 1 to its own previous result, starting at 0. Remaining subtracts Seconds’ result from 90. Clock Text combines Remaining’s result with s, Space On. Clock Label targets Clock and uses Clock Text’s Combined Text.
Use a behavior’s own result
After you drop it, First number (A) contains Seconds · final value. Keep the second number at 1. Initial result: 0.
For a self-reference, keep Seconds selected and drag Seconds’ own green output icon into its first number field. Choose its result (shown as final value in the output reference). Set the second number to 1. At the first tick the clock changes from 90 s to 89 s.
See Timer for repeat and immediate settings.
Wait on the title screen for a few seconds. The clock should stay at 90 s. Launch, and it should begin counting down once per second. Stop this test before zero; you’ll add the ending in Part 3.
For this prototype, you count Timer events to track elapsed seconds. If your own game needs precise timing across interruptions, read elapsed time from a clock instead. Timer events can arrive late.
Make the feel your own
Change one value per experiment, then replay:
- Change Dive gravity from −32 to −24. Does holding feel less forceful?
- Change the assist from 12 to 10. Does the game feel harder on a poor landing?
- Change Hud Tick from 0.2 to 0.5 seconds. Notice how the display becomes less smooth while the ship still moves normally.
Restore the tutorial values before Part 3: World changes and replay. If your build differs, compare it with checkpoint 09-countdown.
