Previously in the Hangman on a rope recipe, we've looked at ropes and how they can bend and move with the object(s) they are bound to. In this recipe, we will look at constraints, which are a much cheaper hinge that can be used on two objects. Specifically, we will hang a primitive pyramid object from a solid and allow it to swing on all axes.
My_Level.cry
within the Sandbox objects/default/primitive_pyramid.cgf
100
Begin by placing down a constraint:
A constraint entity can create a physical constraint between two objects. The objects will be selected automatically during the first update, by sampling the environment in a sphere around the constraint object's world position with a specified radius. The first object (the one that will own the constraint information internally) is the lightest among the found objects, and the second is the second lightest (static objects are assumed to have infinite mass, so a static object is always heavier than a rigid body).
Constraints operate in a special constraint frame. It can be set to be either the frame of the first constraint object (if UseEntityFrame is checked), or the frame of the constraint entity itself. In that frame, the constraint can operate either as a hinge around the x axis, or as a ball-in-a-socket around the y and z axes (that is, with the x axis as the socket's normal). If x limits are set to a valid range (max>min
) and the yz limits are identical (such as both ends are 0), it is the former and if the yz limits are set and not x limits, it's the latter. If all limits are identical (remains 0, for instance), the constraint operates in three degrees of freedom mode (that is, it doesn't constrain any rotational axes). If all limits are set, no axes are locked initially, but there are rotational limits for them.
Here are the definitions of the properties on the constraints.
The following are the constraint properties:
52.14.240.252