# Step 3 - Add Jumping

> Add a grounded jump to Babylon Bros using a key event, a ground check branch, an upward impulse, and a sound in the Flow Graph Editor.

Source: https://doc.babylonjs.com/toolsAndResources/flowGraphEditor/babylonBrosTutorial/jump

## Goal

Make the hero jump on `Space`, but only when grounded, and play a sound. This adds your first conditional branch.

Open this step in the editor: [#LI45XB](https://flowgraph.babylonjs.com/#LI45XB) (scene `P41T6E#2`).

![Jump graph: Space event, ground-check branch, impulse and sound](https://doc.babylonjs.com/img/tools/flowGraphEditor/tutorial/jump.webp)

Run this step:

- [Playground: Babylon Bros - Jump](https://playground.babylonjs.com/#PBXYWT#0) - Tutorial step: run and jump with Space, powered by flow graph #LI45XB.

## Blocks Used

- `KeyDownEvent` (Space)
- `GetLinearVelocity`, `ExtractVector3`, `Abs`, `LessThan` (ground check)
- `Branch` (Control Flow)
- `ApplyImpulse` (Physics)
- `PlaySound` (Audio)

## Step By Step

### 1. Listen For Space

Add `KeyDownEvent` configured for `Space`. Label it "On Space".

### 2. Check Grounded

Read the hero velocity with `GetLinearVelocity`, `ExtractVector3` to get `y`, take `Abs`, then `LessThan` a small threshold. A near-zero vertical speed approximates "on the ground". Feed the result into a `Branch` ("Can jump?").

### 3. Jump And Play Sound

On the `true` path, add `ApplyImpulse` on the `hero` body with an upward vector, then `PlaySound` selecting the jump sound. Use `Sequence` if you want the impulse and sound to fire together cleanly.

## Editor Features To Use

- Set a breakpoint (`F9`) on the `Branch` and run: you can pause and confirm the ground check value before the jump fires.
- Use Debug Mode to confirm only the `true` path lights up when grounded.

## Test And Save

Run, then jump with `Space` while moving. Save the graph; it should match `#LI45XB`. Continue with [Step 4 - Collect Coins](https://doc.babylonjs.com/toolsAndResources/flowGraphEditor/babylonBrosTutorial/coins).

## Further reading

- [Step 2 - Move The Hero](https://doc.babylonjs.com/toolsAndResources/flowGraphEditor/babylonBrosTutorial/movement)
- [Step 4 - Collect Coins](https://doc.babylonjs.com/toolsAndResources/flowGraphEditor/babylonBrosTutorial/coins)
- [Physics Blocks](https://doc.babylonjs.com/toolsAndResources/flowGraphEditor/physicsBlocks)
