Chase
namespace Griff.Scenes;
public sealed class Chase : ComponentGoes 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.
Properties
Section titled “Properties”Around
Section titled “Around”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.
FlipSprite
Section titled “FlipSprite”public bool FlipSprite { get; set; }Flip its sprite to face the way it’s going (art should face right).
GiveUp
Section titled “GiveUp”public float GiveUp { get; set; }Once chasing, it gives up when the target gets this much further away than Range.
IsChasing
Section titled “IsChasing”public bool IsChasing { get; }True while it’s going after the target.
NeedsSight
Section titled “NeedsSight”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.
StopDistance
Section titled “StopDistance”public float StopDistance { get; set; }Stop this close to the target, e.g. for an enemy that shoots from a distance.
Target
Section titled “Target”public string? Target { get; set; }The name of the entity to chase, e.g. “Player”.
TargetEntity
Section titled “TargetEntity”public Entity? TargetEntity { get; set; }The entity it chases. Set it from a script to chase something without looking it up by name.
Events
Section titled “Events”Spotted
Section titled “Spotted”public event Action<Chase>? SpottedRaised when it notices the target and starts chasing.