Skip to content

Body

Makes an entity with a Collider move under velocity and gravity and collide with solids. On an isometric Tilemap, it meets the solid diamonds with the diamond under its collider (as wide as the collider, half as tall, round its middle) and slides along them; on a hex one, its collider meets the solid hexagons’ six sides and slides along them. With Rotates on, it turns too: knocked off its middle it spins, it tips over edges and falls flat, and its box or polygon collider turns with it.

Requires: Collider (the shape that collides)

Needed by: Chase, FightingCharacter, FirstPersonMovement, GridMovement, HingeJoint, Patrol, PlatformerMovement, Pushable, Thruster, TopDownMovement, Weld

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.

  • velocity: [x, y] = [0,0]. World units per second. (Field: a vector.)
  • gravityScale: a number = 1. Multiplier on world gravity. 0 for top-down games or floating things. (Field: a number.)
  • bounciness: a number = 0. How much speed is kept when hitting something: 0 stops dead (the default), 1 bounces back as fast as it hit. Slow bounces settle to a stop, so a bouncing ball comes to rest. (Field: a number.)
  • friction: a number = 0. How quickly it stops sliding along the ground, in world units per second lost each second: a crate shoved or thrown comes to rest instead of gliding on. 0 (the default) keeps sliding; movement components steer bodies themselves either way. (Field: a number.)
  • frozen: true or false = false. Holds it still where it is, like a wall: it doesn’t fall or move, and other bodies bump into it. Untick it (or grab it with the Sandbox Tools) and it moves again. Welded to it, a whole contraption holds still. (Field: on or off.)
  • mass: a number = 1. How heavy it is, for pushes from a Thruster and for sharing movement with what it’s welded or roped to: a heavy crate drags a light balloon down, a light one is lifted. 1 is a crate. Bodies that rotate share their knocks by it too: a heavy ball bowls a light plank over. (Field: a number.)
  • rotates: true or false = false. Lets it turn: hit or pushed off its middle it spins (see Spin), it tips over edges and falls flat, and its box or polygon collider turns with the entity, so others meet it turned. Off (the default), it stays upright whatever hits it, as players and enemies should, and so does its box. Welded to others, they turn as one if they all rotate; hung on a HingeJoint without it, it hangs upright. (Field: on or off.)
  • spin: a number = 0. How fast it turns, in degrees per second: positive turns anticlockwise. Set it to start it spinning. (Only used when rotates is on.) (Field: a number.)
  • grip: a number = 0.6. How well it grips what it touches as it turns, from 0 (ice: it slides off an edge rather than tipping over it) to 1 (it hardly ever slips). Sliding along something it grips slows it, and turns it. (Only used when rotates is on.) (Field: a number.)
  • rollingResistance: a number = 0.1. How much a round one (a CircleCollider) is slowed as it rolls, so a ball comes to rest: 0 rolls on and on, 0.1 (the default) stops a ball rolling at 5 units a second in about 3 seconds, and 1 hardly rolls at all. It rests on a slope up to about this steep (rise over run). With no gravity on it (a top-down game, Gravity Scale 0) it rolls on the ground under the view and slows the same way; set it to 0 for one floating in space. (Only used when rotates is on.) (Field: a number.)
  • asleep: true or false = false. True while it’s asleep: once it and every body that turns touching it have been still for half a second, they fall asleep together and stay exactly where they are, costing a fraction of what they did, until something disturbs them: a hit, a push, its Velocity or Spin set, something pushed into it, or what holds it up moving or going. Tick it to start it asleep, so a tower built resting on itself stands until something knocks it; untick it to wake it. Only one that Rotates sleeps. (Only used when rotates is on.) (Field: on or off.)
  • stillFor: a number = 0. Seconds it has been all but still (see Asleep): at half a second, and every body that turns touching it with it, it falls asleep. The game counts it. (Only used when rotates is on.) (Not sent in a network game: each machine has its own.) (Field: a number.)

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.

  • Speed (a number). How fast it’s going, in world units per second, whichever way.
  • Height (a number). How high it is: its entity’s height in the world.

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

  • speed: a number. How fast it’s going, in world units per second, whichever way.
  • height: a number. How high it is: its entity’s height in the world.
  • heldStill: true or false. Held still for the step: frozen, or paused with its group (see Entity.IsPaused). Others bump into it as into a wall.
  • inertia: a number. How hard it is to turn (its moment of inertia), from its Mass and its collider’s size: a long plank turns more slowly than a small crate of the same weight.
  • centerOfMass: [x, y]. What it turns round: its collider’s middle in the world (where a polygon balances), or its position without a collider.
  • isGrounded: true or false. True if the body rested on something below it during the last physics step.
  • ground: an entity: its name, id or path. What the body is standing on (a platform, the floor’s tilemap), or null in the air. When that moves, the body rides along with it, so platforms moved by scripts or tweens carry whoever is on them.
  • wallSide: a whole number. -1 if a wall stopped the body moving left during the last physics step, 1 if one stopped it moving right, else 0: for wall jumps and slides, or turning round.
  • airTime: a number. Seconds since the body last stood on something: 0 while it’s grounded.
  • isDroppingThrough: true or false. True while the body falls through one-way platforms (see DropThrough).

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