Physics & Constraints
These puzzles are used to simulate physics behavior and restrict the movement of objects.
- Puzzles Reference
create physics world
Initializes the physics engine using the specified gravity and frame-per-second parameters. The default gravity value of 9.8 corresponds to Earth surface conditions. Zero value means no gravity as in space. The higher fps value the better simulation quality at the expense of performance.
Under the hood, this puzzle also enables collision detection and automatic synchronization with graphics.
create physics body
Creates a physics body from a specified object, of dynamic, kinematic, static or ghost type. Assigns the collision shape and sets the mass for the body (valid for dynamic bodies only). Also works for a list of objects, a group (or a list of groups) or with the all objects puzzle.
Physics body types:
- dynamic - moved by the physics engine, influenced by collisions and collide with other bodies.
- kinematic - moved by animation or user action. Dynamic objects will be pushed away but there is no influence from dynamics objects.
- static - cannot move but collide with other bodies.
- ghost - similar to kinematic but does not produce any collision response. Use it to detect collision between bodies (for example to implement proximity sensor).
Physics body shapes:
- box - a box-shaped bounding.
- sphere - a sphere-shaped bounding.
- mesh - a mesh shape.
- capsule - a capsule shape stretched along up-down axis.
- cone - a cone shape stretched along up-down axis.
- cylinder - a cylinder shape stretched along up-down axis.
For performance reasons, give priority to primitive physics shapes (boxes, spheres, capsules, cones and cylinders) over mesh shapes. Also, static meshes have much better performance than dynamic, kinematic and ghost.
remove physics body
Removes physics from a specified object by destroying the physics body associated with it. Also works for a list of objects, a group (or a list of groups) or with the all objects puzzle.
physics body params
Sets parameters for the physics body associated with a specified object. Also works for a list of objects, a group (or a list of groups) or with the all objects puzzle.
- friction - coefficient of resistance of relative motion of solid bodies sliding against each other.
- linear damping - coefficient of resistance that will slow down a moving object: 0 - no damping (e.g. free fall), 1 - maximum damping (e.g. object falls with no acceleration). Input values are clamped to [0, 1] range.
- angular damping - coefficient of resistance that will slow down a rotating object: 0 - no damping, 1 - maximum damping. Input values are clamped to [0, 1] range.
- restitution - coefficient of elasticity: 0 - body is not elastic like clay, 1 - body behaves like being made from rubber.
When two bodies collide, friction and restitution parameters of both of them are taken into consideration.
Applies Force, Gravity, Linear Velocity, Angular Velocity, Impulse, Torque, Torque Impulse or Position to the physics body associated with a specified object, in a specified direction in world space. Also works for a list of objects, a group (or a list of groups) or with the all objects puzzle.
- force - push a body in a specified direction.
- gravity - assign gravity individually for a specified body.
- linear velocity - set movement speed.
- angular velocity - set rotation speed.
- impulse - acts like Linear Velocity but also takes the body mass into account (heavier objects will acquire less speed).
- torque - spin a body in a specified direction.
- torque impulse - acts like Angular Velocity but also takes the body mass into account (heavier objects will acquire less rotation speed).
- linear factor - set positional degrees of freedom for the specified body. For example by setting Z component to zero you can disable up-down (Blender, Max) or front-back (Maya) movement of the body.
- angular factor - set rotational degrees of freedom for the specified body. For example by setting Z component to zero you can disable whirling the body around up-down (Blender, Max) or front-back (Maya) axis.
- position - set body position (works like the snap body puzzle).
set body state
Change the state to the physics body associated with a specified object. Also works for a list of objects, a group (or a list of groups) or with the all objects puzzle.
- activate - activate sleeping physics body.
- sleep - force sleeping state for the body.
- enable simulation - enable body simulation (enabled by default).
- disable simulation - disable body simulation.
- reset - clear all forces and velocities applied to the physics body.
- enable contact response - allow body to collide with other bodies (enabled by default).
- disable contact response - disable body colliding.
- make dynamic - make body dynamic.
- make kinematic - make body kinematic.
- make static - make body static.
- enable deactivation - allow body to turn into sleeping state after a period of inactivity (enabled by default).
- disable deactivation - disable body sleeping.
on simulation tick
Trigger puzzles specified in the *do" slot just before or just after the physics simulation tick.
Physics simulation tick corresponds to the FPS value specified when creating physics world and does not coincide with rendering frame. As such, we recommend that you apply forces/velocities/impulses before simulation tick and detect collisions between your bodies after simulation tick. This way you can achieve more stable and realistic simulations.
Moves a physics body associated with a specified object, and the object itself, to the position of another object by copying its transform data. Also copies rotation. Does not work with lists, groups or the "all objects" puzzle.
Works similar to apply vector / Position puzzle.
detect collisions and collision info
Detects if there is a collision at the moment of a specified body with another body (or any body from a list or a group). If there is a collision, the puzzles in the "if touching do" slot are triggered, otherwise - in the "if not touching do".
The "detect collisions" puzzle triggers either of its callback slots every rendering frame.
The collision info puzzle outputs a dictionary with the following fields:
- objectA - the name of the first colliding body.
- objectB - the name of the second colliding body.
- distance - distance between points of collisions.
- positionOnA - XYZ coordinates of the collision point on the first object.
- positionOnB - XYZ coordinates of the collision point on the second object.
- normalOnB - XYZ components of the normal vector at the collision point on the second object.
If an object is not parented to another object, the constraints will work in world space. Otherwise they will work in the parent object's space - you can select the parent object in 3ds Max or Blender to show up the coordinate axes.
Creates a constraint to limit object position, rotation or scale along a selected axis. Constraint id should be unique, otherwise an existing constraint with the same id will be replaced. The min and max slots specify the range between which the movement is allowed.
Creates a constraint to copy object position, rotation or scale from another object. Constraint id should be unique, otherwise an existing constraint with the same id will be replaced.
remove / mute / unmute constraint
Removes, mutes or unmutes a constraint assigned to a specified object. Other constraints assigned to this object (if any) will remain intact.
Having Troubles with Puzzles?
Seek help on the forums!