Skip to content

EdgePointer

Points the way to something off the screen, as a strategy game’s objective marker does: while its Target is out of the camera’s view, the entity sits on the screen’s edge (in by Margin) where the line from the screen’s middle to the target crosses it, turned to point at the target, and slides along the edge as the camera pans or zooms. Once the target is in view it hides, or sits over the target (see InView). Draw its sprite pointing right. A Button on it whose Do is “Glide” glides the camera there on a click; a Text inside it showing its Distance output (“{0:0} m”) says how far off the target is, and stays upright.

It’s pinned to the main camera’s screen as a ScreenAnchor is, laid out after them each frame, and keeps its size as the camera zooms with the camera’s Camera.HudSize and the player’s UI Scale. Its target goes by its position. It decides whether its entity is shown, so to hide it some other way, hide what it’s inside. The Scene view shows it where it’s placed; it only moves while the game runs.

Works with: Sprite (an arrow drawn pointing right); Button (Do: Glide, to glide the camera to the target on a click)

In a network game, each machine keeps its own entity with this on it: it isn’t sent.

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 = null. The name of the entity to point at, e.g. “Goal” (found as names find entities). A script, or a Trigger’s Point At, changes it as the goal moves on; empty points at nothing, and it hides. (Names an entity.) (Field: an entity’s name.)
  • margin: a number = 0.75. How far in from the screen’s edges it sits, in world units of the HUD (as a ScreenAnchor’s Offset is): room for half of it, and for a bar along the edge. (Field: a number.)
  • inView: one of Hide, OverTarget = “Hide”. What it does while the target is in view: hide (the default), or sit over the target pointing down at it. (Field: one of its values.)
  • overTarget: [x, y] = [0,1]. Where it sits from the target while that’s in view, in world units: (0, 1) just over a worker’s head. Past the screen’s edge it stays on the edge. (Only used when inView is OverTarget.) (Field: a vector.)

What anything can make it do with no code: a Trigger’s do when its message arrives, a Contraptions Wire’s input as its signal comes on, a script’s Game.Do(entity, “Name”).

  • PointAt (done with a name, its name: a trigger’s with). Points at the entity with this name from now on: a Trigger or a script moving the goal on. Empty points at nothing.
  • Glide. Glides the camera over to the target with its CameraControls (see CameraControls.GlideTo) and leaves it the player’s there: what a Button on it does with Do set to Glide. Nothing happens without a target, or without Camera Controls on the camera.

What anything can read with no code: a Counter’s, Bar’s or Text’s output, a Contraptions Wire’s output as its signal; Text shows names too, the rest read numbers, true as 1.

  • Distance (a number). How far the target is from the middle of the screen, in world units: a Text inside it can show it (“{0:0} m”).

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 it points at. Set it from a script to point at something without naming it; it holds until Target changes.
  • isOnEdge: true or false. True while the target is out of view and it’s on the screen’s edge pointing at it.
  • distance: a number. How far the target is from the middle of the screen, in world units: a Text inside it can show it (“{0:0} m”).

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