Skip to main content

Hinge

A hinge is a joint between 2 objects.

You can add these with Scene's add_hinge, but you are recommended to instead use the core hinge function.

If you use add_hinge, you'll connect objects, but without a visible hinge attachment the user can remove. This is rarely useful, since it prevents the user from modifying or removing the joint. But, for example, if you select a Simulon, you'll see some invisible attachments for its spring, bolt, and hinge.

So, if you want to add a visible hinge the user can remove (even if you want it to be invisible), use core's hinge. Otherwise, you can use add_hinge.

The below functions concern returned hinge joints from add_hinge, not core's hinge.

Fields


.id

Identifier for the hinge. Is a number.

Functions

note

Make sure to use :function() and not .function(), or you'll get an error


:destroy()

Destroys the hinge.


:is_destroyed()

Returns whether or not the hinge still exists.


:get_local_anchor_a()

Gets the anchor of the hinge on the first object as a Vec2.


:get_local_anchor_b()

Gets the anchor of the hinge on the second object as a Vec2.


:set_local_anchor_a()

Moves the anchor of the hinge on the first object to a Vec2. Note that this currently only works if the object_a is nil.


:set_local_anchor_b()

Moves the anchor of the hinge on the second object to a Vec2. Note that this currently only works if the object_a is nil.


:get_world_anchor_a()

Gets where the first anchor of the hinge is in the world as a Vec2.


:get_world_anchor_b()

Gets where the second anchor of the hinge is in the world as a Vec2.


:get_force()

Gets the force applied by the hinge as a Vec2.


:get_angle()

Gets the angle of the hinge in radians as a number.


:get_torque()

Gets the torque applied by the hinge as a number.


:get_motor_enabled()

Returns whether or not the hinge's motor is enabled.


:set_motor_enabled()

Enables or disables the hinge's motor.


:get_motor_speed()

Gets the speed of the hinge's motor as a number.


:set_motor_speed()

Sets the speed of the hinge's motor.


:get_max_motor_torque()

Gets the maximum torque of the hinge's motor as a number.


:set_max_motor_torque()

Sets the maximum torque of the hinge's motor.


:get_motor_current_torque()

Gets the current torque of the hinge's motor as a number.


:get_object_a()

Gets the first object the hinge is attached to. Can be nil if the hinge is connected to the world on that end.


:get_object_b()

Gets the second object the hinge is attached to. Can be nil if the hinge is connected to the world on that end.


:get_collide_connected()

Gets whether or not the object A will collide with object B


:get_reference_angle()

Gets the reference angle of the hinge in radians as a number.


:get_limit()

Gets whether or not the hinge's limits are enabled.


:get_lower_limit_angle()

Gets the lower limit of the hinge in radians as a number.


:get_upper_limit_angle()

Gets the upper limit of the hinge in radians as a number.


:get_attachment()

Returns the attachment of the hinge as a Attachment. Can be nil.


:set_limit()

Sets whether or not the hinge's limits are enabled.


:set_lower_limit_angle()

Sets the lower limit of the hinge in radians.


:set_upper_limit_angle()

Sets the upper limit of the hinge in radians.


:get_type()

Returns "hinge". Mainly used after object:get_joints() to determine what type of joint it is.