Skip to content

Chase

namespace Griff.Scenes;
public sealed class Chase : Component

Goes after a Target once it’s within Range, with no code: zombies, bats, homing mines. On a body with gravity it only runs left and right; without gravity it heads straight for the target, or around walls with Around. Needs a Body.

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

public string? Around { get; set; }

The name of a tilemap to find a way around the walls of, e.g. “Level” (bodies without gravity only). Empty heads straight for the target.

public bool FlipSprite { get; set; }

Flip its sprite to face the way it’s going (art should face right).

public float GiveUp { get; set; }

Once chasing, it gives up when the target gets this much further away than Range.

public bool IsChasing { get; }

True while it’s going after the target.

public bool NeedsSight { get; set; }

Only notice the target when nothing solid is in the way.

public float Range { get; set; }

How close the target has to be to notice it, in world units. 0 notices it anywhere.

public float Speed { get; set; }

World units per second.

public float StopDistance { get; set; }

Stop this close to the target, e.g. for an enemy that shoots from a distance.

public string? Target { get; set; }

The name of the entity to chase, e.g. “Player”.

public Entity? TargetEntity { get; set; }

The entity it chases. Set it from a script to chase something without looking it up by name.

public event Action<Chase>? Spotted

Raised when it notices the target and starts chasing.