GridChase
Steps its GridMovement after a Target once it’s within Range, tile by tile and around walls, with no code: a roguelike’s monsters, a maze’s ghosts, a dungeon’s slimes. It stops next to the target (see StopDistance) and turns to face it, so an Attack swings its way. It steps as fast as its grid movement’s Step Time lets it, or with a TurnTaker that has actions, a step an action. With a GridPatrol too, it walks its route until it spots the target, and goes back to it once it gives up.
Requires: GridMovement
Works with: GridPatrol (walks its route until it spots its target); Attack (swings at the target once it’s next to it)
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”. In a network game it chases the nearest player. (Names an entity.) (Field: an entity’s name.)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.)needsSight: true or false = false. Only notice the target when nothing solid is in the way. (Field: on or off.)stopDistance: a whole number = 1. How many steps from the target it stops: 1 stops next to it (diagonally next to it too, if its grid movement is Diagonal; on a hex map, in any of the six hexagons round it), 2 keeps a cell between them, for one that shoots. 0 walks into the target’s cell; a target with a solid collider blocks it, so it bumps into it each step instead (Bumped, and its Bump Sound): a roguelike’s attack. (Field: a number.)
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.wasNear: true or false. Whether it was within its stop distance last time it looked, so Reached is raised once each time it gets there.
Scripts use it as GridChase: its methods, events and values that aren’t saved with the scene.