Skip to content

Follow

Moves the entity after another one, smoothly: a camera after the player, a pet after its owner. No code needed: put it on the camera and name the Target. With StayInside, a camera never shows past the edges of the level. Applied while the game runs, after physics, so it follows where things ended up this frame.

Works with: Camera (a camera that follows the player)

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 follow, e.g. “Player”. (Names an entity.) (Field: an entity’s name.)
  • smoothing: a number = 6. How quickly it catches up: higher is snappier, 0 sticks exactly to the target. (Field: a number.)
  • offset: [x, y] = [0,0]. Where to sit relative to the target, in world units, e.g. (0, 2) to see more above a platformer’s hero. (Field: a vector.)
  • deadZone: [x, y] = [0,0]. A box around the follower, in world units, that the target can move about in without the follower moving. (0, 0) follows every step; something like (2, 1) keeps a platformer’s camera still for small hops. (Field: a vector.)
  • lookAhead: a number = 0. Seconds of the target’s movement to look ahead by, so a camera shows more of where the player is heading. (Field: a number.)
  • stayInside: text = null. The name of an entity whose area the follower stays inside: a tilemap’s grid, a box collider, or a sprite. On a camera the whole view stays inside, so the game never shows past the level’s edges. (Names an entity.) (Field: an entity’s name.)

Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.

  • targetEntity: an entity: its name, id or path. The entity being followed. Set it from a script to follow something without looking it up by name.
  • currentRoom: an entity with a Room: its name, id or path. The Room a camera is keeping to, in place of StayInside; set by the game as the target moves from room to room.
  • isChangingRoom: true or false. True while the camera is sliding over to a new room.

Scripts use it as Follow: its methods, events and values that aren’t saved with the scene.