Skip to content

Tilt

Nudging and tilting a pinball table, with no code: its NudgeAction bumps the table, giving every ball on it a small push (and shaking the view), but nudge too often in a short time and it warns, then tilts: the flippers drop and stay down and the bumpers, kickers, targets and lanes go dead until the ball drains.

Part of the Physics Games module: Physics puzzlers: a Slingshot to pull back and launch shots from, and Breakable things (planks, panes, blocks, pigs) that crack and break on hard knocks; a LevelGoal that wins a level once its targets are down (with a bonus for the shots left, and one to three stars) or loses it once the shots run out; a Slingshot and a Tower to make from the Entity menu (Genres, Physics Games); and the Physics template, levels of wood, glass and stone to knock down.

Each nudge adds one to its Danger, which falls back by one every Settle seconds. A nudge that takes it past one warns (its WarningMessage, “DANGER” over the table); past Warnings plus one, it tilts. It covers what’s inside the entity its Within names (or stands in its area), or the whole scene. A Drain it covers puts it right as the ball drains; its Reset action does too.

Works with: Flipper (tilted, they drop and stay down); Drain (puts it right as the ball drains)

Takes the player’s input only while it has focus (its Controllable): its Focus action hands it the input and takes it from everything else the same player plays.

Draws itself (its entity draws at Order 1000 unless it has a Sprite, whose order counts).

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.

  • within: text = null. The table it covers, by an entity’s name: the balls, flippers, bumpers, targets and lanes inside it or standing in its area. Empty covers the whole scene. (Names an entity.) (Field: an entity’s name.)
  • nudgeStrength: a number = 3. How hard a nudge pushes each ball, in world units a second. (Field: a number.)
  • nudgeDirection: [x, y] = [0,1]. Which way a nudge pushes the balls, in the world: (0, 1) is up the table. Holding left or right as it’s nudged (the arrows, A and D, the stick) pushes them that way too. (A direction, x right and y up: [0, 1] is up, [1, 0] right, [1, 1] up and to the right. The Inspector has a compass of the eight ways; with Distance Handles the Scene view draws it as an arrow to drag round.) (Field: its own editor: Direction.)
  • warnings: a whole number = 2. How many nudges close together only warn: the next tilts. (Field: a number.)
  • settle: a number = 1.5. Seconds for each nudge to wear off: nudges further apart than this never add up to a tilt. (Field: a number.)
  • nudgeAction: text = “Nudge”. The input action that nudges the table: “Nudge” is N, the up arrow or the gamepad’s B. (Names an input action.) (Field: a name.)
  • controllable: true or false = true. Untick it to have it ignore the keys and gamepad (its actions and scripts still work). Its Focus action ticks it and unticks it on everything else the player plays. (Field: on or off.)
  • showText: true or false = true. Shows “DANGER” over the table for a moment after a warning, and “TILT” while it’s tilted, at its position. (Field: on or off.)
  • textColor: a color, “#RRGGBB” or “#RRGGBBAA” = “#FF5040FF”. The color of its “DANGER” and “TILT”. (Only used when showText is on.) (Field: a color.)
  • textSize: a number = 1.2. How tall its “DANGER” and “TILT” are, in world units. (Only used when showText is on.) (Field: a number.)
  • shake: a number = 0.12. How hard the view shakes with each nudge; 0 doesn’t shake it. (Field: a number.)
  • nudgeSound: text = null. A sound played with each nudge, e.g. “Sounds/thud.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
  • warningSound: text = null. A sound played as it warns. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
  • tiltSound: text = null. A sound played as it tilts. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
  • warningMessage: text = null. A message sent as it warns, with how many warnings it has given this ball as its data, e.g. “Danger”. (Names a message.) (Field: a name.)
  • tiltMessage: text = null. A message sent as it tilts, e.g. “Tilted”. (Names a message.) (Field: a name.)
  • danger: a number = 0. How close it is to tilting: one for each recent nudge, falling back by one every Settle seconds. (Field: a number.)
  • tilted: true or false = false. True once it has tilted, until the ball drains (or its Reset action). (Field: on or off.)
  • nudges: a whole number = 0. How many times the table has been nudged. (Field: a number.)
  • warningFor: a number = 0. Seconds “DANGER” still shows. Set by the game. (Field: a number.)

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”).

  • Nudge. Nudges the table: each ball gets a little push, and it’s one nudge nearer tilting.
  • Tilt. Tilts it now: the flippers drop and the table goes dead until the ball drains.
  • Reset. Puts it right: not tilted, and no nudges counting against it.
  • Focus. Gives its entity the player’s input: whatever there and inside it has focus, and everything else the same player plays loses it (a platformer’s player stops on the arrow keys while a board takes them).

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.

  • Danger (a number). How close it is to tilting: one for each recent nudge, falling back by one every Settle seconds.
  • Tilted (true or false). True once it has tilted, until the ball drains (or its Reset action).
  • Nudges (a whole number). How many times the table has been nudged.

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