HingeJoint
Pins its Body to another body (To), or to a point in the world, at one point (its Anchor), so it turns there: a wheel on a cart, a door, a flipper, a seesaw, a windmill. It can be kept within a range of angles (Limit) and turned by a motor (Motor), and the two it joins don’t bump into each other unless Collide is ticked. Tick Body.Rotates on the body for it to swing round (Entity > Add Hinge does); without it, it hangs upright from the hinge, as a Ferris wheel’s seats do. What it’s hinged to turns with it if that rotates too, and is pulled about by it if it moves under physics; anything else (a player, a wall, a platform moved by a script) just carries the hinge along.
The two are joined as they stand when the game starts (see Joined): the hinge stays at that point on each of them, and its angles count from how they’re turned then. In the Scene view, drag the hinge’s knob to move it and the ends of its arc to set its limits.
Requires: Body (what turns on the hinge)
Needed by: Flipper
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.
to: text = null. What it’s hinged to, by name: the nearest entity called that. Empty pins it to the world, where the hinge is when the game starts. (Names an entity.) (Field: an entity’s name.)anchor: [x, y] = [0,0]. Where the hinge is on this entity, from its position, in its own units (before its scale, turned with it): (0, 0) is its middle, as a wheel’s; (-2, 0) one end of a plank 4 long, as a door’s. (Field: a vector.)collide: true or false = false. Let the two it joins bump into each other. Off (the default), they pass through each other where they meet. (Field: on or off.)friction: a number = 0.05. How stiffly it turns, from 0 (it swings on and on) to 1 (a stiff hinge that stops a swinging door soon, a little off straight down): the more weight on it, the harder it is to turn. The default, 0.05, lets wheels roll on and slows a pendulum over a while. A running Motor takes no notice of it. (Field: a number.)limit: true or false = false. Keep it within LowerAngle and UpperAngle: a door that opens one way, a flipper. (Field: on or off.)lowerAngle: a number = -45. How far it can turn clockwise (negative) from how it started, in degrees, as far as -180 (half a turn). (Only used when limit is on.) (Field: a number.)upperAngle: a number = 45. How far it can turn anticlockwise (positive) from how it started, in degrees, as far as 180 (half a turn). (Only used when limit is on.) (Field: a number.)motor: true or false = false. Turn it with a motor, at MotorSpeed as far as MotorStrength lets it: a wheel that drives a cart, a windmill. A switch or a wire into its “Power” turns the motor on and off (a flipper on a button). (Field: on or off.)motorSpeed: a number = 180. How fast the motor turns it, in degrees a second: positive turns it anticlockwise. (Only used when motor is on.) (Field: a number.)motorStrength: a number = 100. How hard the motor can turn it (the most torque it has): 100 turns a crate at full speed in an instant, and lifts a plank 4 long by its end; a heavy load turns more slowly or stalls. (Only used when motor is on.) (Field: a number.)
Joined
Section titled “Joined”joined: true or false = false. True once the game has joined the two as they stood (it sets OtherAnchor and StartAngle). Untick it to join them again as they are now, where Anchor is. (Field: on or off.)otherAnchor: [x, y] = [0,0]. Where the hinge is on what it’s hinged to, from its position in its own units (or, hinged to the world, where it is in the world): the game sets it as it joins them. (Only used when joined is on.) (Field: a vector.)startAngle: a number = 0. How the two were turned against each other as they were joined, in degrees: the game sets it. (Only used when joined is on.) (Field: a number.)
Actions
Section titled “Actions”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”).
Reverse. Turns the motor the other way.
Outputs
Section titled “Outputs”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.
Angle(a number). How far it has turned on the hinge from how it started, in degrees (positive anticlockwise), against what it’s hinged to: from -180 to 180.
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.
angle: a number. How far it has turned on the hinge from how it started, in degrees (positive anticlockwise), against what it’s hinged to: from -180 to 180.worldAnchor: [x, y]. Where the hinge is in the world.otherEntity: an entity: its name, id or path. What it’s hinged to (see To), or null for the world.
Scripts use it as HingeJoint: its methods, events and values that aren’t saved with the scene.