Chase
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.
Requires: Body
Works with: Patrol (patrols until it spots its target)
Properties
Section titled “Properties”Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.
target: text = “Player”. The name of the entity to chase, e.g. “Player”. (Names an entity.) (Field: an entity’s name.)speed: a number = 3. World units per second. (Field: a number.)range: a number = 6. How close the target has to be to notice it, in world units. 0 notices it anywhere. (A distance: the Scene view draws it as a circle around the entity, with a handle to drag.) (Field: a number.)giveUp: a number = 2. Once chasing, it gives up when the target gets this much further away than Range. (Only used when range is set.) (Field: a number.)stopDistance: a number = 0. Stop this close to the target, e.g. for an enemy that shoots from a distance. (A distance: the Scene view draws it as a circle around the entity, with a handle to drag.) (Field: a number.)needsSight: true or false = false. Only notice the target when nothing solid is in the way. (Field: on or off.)around: text = null. 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. (Names an entity.) (Field: an entity’s name.)flipSprite: true or false = true. Flip its sprite to face the way it’s going (art should face right). (Field: on or off.)
While the game runs
Section titled “While the game runs”Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.
isChasing: true or false. True while it’s going after the target.targetEntity: an entity: its name, id or path. The entity it chases. Set it from a script to chase something without looking it up by name.
Scripts use it as Chase: its methods, events and values that aren’t saved with the scene.