Skip to content

Bouncer

namespace Griff.Scenes;
public sealed class Bouncer : Component

A spring, jump pad or bumper, with no code: bodies touching it from the Direction side are sent flying that way at Strength. Works on solid colliders (land on it) and triggers (pass through it). A PlatformerMovement launched by it gets its air jumps and dash back.

This is a component: its saved properties are on its component page.

public Vector2 Direction { get; set; }

Which way it sends them: (0, 1) is up, (1, 0) right, (1, 1) up and to the right.

public string? Layers { get; set; }

The collision layers it launches, e.g. “Player”. Empty launches any body.

public string? Sound { get; set; }

A sound played on each bounce, e.g. “Sounds/boing.wav”.

public bool Squash { get; set; }

Squash and stretch its entity with each bounce.

public float Strength { get; set; }

How fast it sends things off, in units per second.

public Vector2 Way { get; }

The Direction as a unit vector (up if it’s zero).

public bool AcceptsLayer(string? layer)

True if it launches things on collision layer layer.

public event Action<Entity>? Bounced

Raised with whatever it launched.