Learn

J! Code Academy

Making a Bounce Pad

Hosted by Icoso

Build a BouncePad trait and use a Box Area trigger to launch players upward. Learn Box Areas, onEntityCollisionStart, getTrait, and characterJump with cancel for consistent bounces.

Script

Hello hello and welcome to Episode 4 of Jamango! Academy! Today we're coding bounce pads to launch players into the air. Great for vertical movement and memorable moments! We'll use traits, collision detection, and some new methods — let's bounce right in.

Box Areas (triggers)#

Box Areas are invisible zones that detect when players or props enter them — like pressure plates or triggers. They don't do anything on their own, but our code can react when something steps inside. We'll use a Box Area to detect when players step on a Bounce Pad and then launch them upward with physics.

Define the BouncePad trait#

We'll start by defining a trait similar to last episode's Spin trait, but for bouncing.

ts
export const BouncePad = J.defineTrait(
  "BouncePad",
  J.schema.object({
    bounceForce: J.schema.number(),
  }),
  {
    name: "BouncePad",
    description: "Bounces the player!",
    icon: "⬆",
    color: "#18d",

Attach this trait to your Box Area using the wrench tool. Set bounceForce to something like 20 for testing.

Detect player collision and apply bounce#

We'll detect when an entity with the BouncePad trait collides with another entity (the player), then make the player jump using the trait's bounceForce.

ts
J.onEntityCollisionStart(
  {
    source: [BouncePad],
  },
  (bounceId, targetId) => {
    const bouncePadTrait = J.getTrait(bounceId, BouncePad);

    // Launch the player upward using the bounceForce from the trait.
    // The third argument cancels other motion for a consistent feel.
    J.characterJump(targetId, bouncePadTrait.bounceForce, true);

Tuning bounceForce#

Try a few values to feel the difference:

  • 10: a small hop — great for short gaps
  • 20: a strong launch — great for reaching higher sections
  • 50: chaos mode — think sky islands, secrets, or dramatic jumps

And that's it! You've built a functional bounce pad using Traits, Box Areas, and collision detection. Whether you're making a chill platformer or a vertical gauntlet, bounce pads add that extra lift.

Share your builds in #Creator-Logs on Discord, ask questions any time, and keep experimenting!