Physics

The physics component provides an entity with rigid body physics. For more details on all properties associated with the physics component and how to use the physics component with scripting, please see the API documentation.

Please also visit the physics section of our documentation, which gives a more in-depth overview of everything you need to know about physics in ProtoTwin.

Properties

The physics component properties that are accessible through the inspector.

Body

A rigid body is a solid object that can experience force but does not deform as a result. It is one of the following values:

  • Attached: No physics body. The collider will be rigidly attached to the closest ancestor that has a rigid body.
  • Dynamic: The rigid body can experience forces due to collisions and externally applied forces such as gravity.
  • Kinematic: The rigid body does not experience forces but may extert forces on other rigid bodies through collisions.

The attached body type is typically used to create composite/compound physics geometry. For example, a table can be composed of 5 box colliders. The parent entity can have a dynamic rigid body with no collider and its children (representing the top and four legs) can each have a box collider which gets attached to the parent. Composite/compound physics geometry is almost always preferable to using fixed joints since it is more efficient and the attachment is perfectly rigid.

Entities with dynamic rigid bodies should not be moved directly. Instead, they should be moved by applying forces or by setting their linear or angular velocities. Entities with kinematic rigid bodies must be moved by setting the position of the attached entity. Please see the physics bodies page for more information.

Collider

Colliders provide collision geometry to a rigid body. It is one of the following values ordered from the most to least computationally efficient:

  • None: No collision geometry.
  • Plane: Infinite plane aligned with the local yz-plane and normal in the local x-axis. It must only be used with kinematic rigid bodies.
  • Sphere: Bounding sphere around the entity and its descendants.
  • Box: Bounding box around the entity and its descendants.
  • Convex: Convex hull around the entity and its descendants.
  • Custom: Custom physics mesh generated by the collider tool.
  • Nonconvex: Triangle mesh for the entity and its descendants. It must only be used with kinematic rigid bodies.

Note that the plane and nonconvex types may only be applied to entities with kinematic rigid bodies. This is because these colliders have no volume, so their inertia tensor is not well defined. The sphere and box types are bounding colliders. They effectively merge the mesh of the entity and its descendants before computing the bounding geometry. The convex and nonconvex types create a convex/non-convex collision shape for the entity and each of its descendants.

It is generally recommended to use the most simple collision geometry possible. Sphere, box and convex are computationally efficient and are relatively stable. The computational efficiency of custom colliders depends mostly on the number of convex hulls that get generated. You should avoid the nonconvex geometry type where possible, since it is computationally expensive and suffers from tunneling, where another fast-moving rigid body may pass through or become stuck inside the mesh.

Custom colliders are composed of one or more convex hulls, a signed distance field or a tessellated triangle mesh. They can be used to represent pretty much any complex shape that has concavities. Custom colliders are typically more efficient and more stable than nonconvex triangle meshes. They can also be used with dynamic rigid bodies, unlike nonconvex colliders. Please see the physics colliders page for information about the supported collider types.

Mass

The mass of the rigid body. The mass is only displayed for dynamic rigid bodies. The property is hidden and ignored for the attached and kinematic body types. This is because kinematic bodies effectively have infinite mass.

Joints

The collection of dynamic physics joints. Joints constrain one or more degrees of freedom between two rigid bodies. It determines how two rigid bodies move relative to each other. Constraints are one of the following values:

  • Prismatic: Constrains the rigid body so that it is only permitted to move along a linear axis relative to the base.
  • Revolute: Constrains the rigid body so that it is only permitted to rotate about an axis relative to the base. The axis and anchor define the plane which the entity is allowed to move in.
  • Spherical: Constrains the rigid body so that it is only permitted to rotate about a point relative to the base. A spherical (ball) joint permits rotational motion about any axis.
  • Path: Constrains the rigid body such that it is only permitted to move along a path relative to the base. The anchor point gets projected onto the path and moves along the curve specified by the path component.
  • Fixed: Constrains the rigid body so that it is locked relative to the base.

You can click the add button to add a new joint to the entity and click the remove button to delete the joint. The base property specifies the base entity to which the joint is connected. An empty (null) base specifies that the joint is attached to the virtual world. The axis and anchor properties specify the direction and point about which the entity is permitted to move relative to the base. You can click the select button to select a feature from a mesh, to be used as the anchor or axis. Hover over the feature that you want to select and left-click to confirm the selection. You can right click whilst hovering to negate the direction of the axis.

Prismatic, revolute and path joints can be driven by dynamic motors. Spherical and fixed joints may not be driven by dynamic motors. You can select an existing motor to be bound to the joint, or click the add button to create a new motor component attached to the selected entity and automatically bound to the joint. Please see the physics joints page for more information about configuring dynamic joints.

Layer

The physics collision layer can be used to filter collisions. If no collision layer is assigned, the rigid body will collide with all other rigid bodies by default. Click the add button to create a new collision layer, or the edit button to edit an existing collision layer. Doing this replaces the inspector with a new pane, allowing you to specify a row of the collision layer matrix. This matrix defines whether two layers can interact through collisions or not. Please the physics layers page for further information about physics collision layers.

Material

The physics material can be used to calculate the contact properties for collisions. Click the add button to create a new physics material, or the edit button to edit an existing physics material. Doing this replaces the inspector with a new pane, which allows you to configure the material properties. Each physics material must have a unique name. Other properties include coefficients for static friction, dynamic friction, restitution and damping.

Static friction forces are applied between two rigid bodies that are at rest with respect to each other. Dynamic friction forces are applied between two rigid bodies that are sliding relative to each other. The friction coefficient for a contact point between two rigid bodies is calculated by multiplying the friction coefficient values of each material. The friction force is calculated by the physics engine and is proportional to the friction coefficients, area of contact and normal force.

It is possible to define soft materials by using a negative restitution with a positive damping coefficient. This can be useful where one part needs to slide between another part and there are tolerances built into the meshes. Soft materials can be used to increase stability of the physics by damping oscillations. Please see the physics materials page for more information about physics materials.

Advanced

The properties in the advanced category allow you to specify additional physics-related properties:

  • Axis Locks: The world axes for translation and/or rotation that should be locked.
  • Linear Damping: The linear damping coefficient for the rigid body.
  • Angular Damping: The angular damping coefficient for the rigid body.
  • Linear Velocity: The linear velocity for the rigid body.
  • Angular Velocity: The angular velocity for the rigid body.
  • Contact Offset: The distance between two colliders at which contact points are detected. The default value is -1. When the contact offset is equal to -1, we will try to automatically determine an appropriate contact offset based on the size of the graphics mesh. It’s very rare that you need to change the default value.
  • Rest Offset: The distance from the surface of the collider at which objects come to rest.

Contact points are generated between two colliders when the distance between them is less than the sum of their contact offsets. The distance between the two colliders at rest is specified by the sum of their rest offsets. The rest offset must be less than the contact offset. A small positive rest offset allows colliders to slide more freely over each other. It is very rare that you will need to change the contact offset or rest offest.

The damping coefficients can be used to dissipate linear and angular momentum, which can be useful for approximating air resistance and joint friction. The value of the coefficients specify 1/t, where t is the time over which the rigid body should lose half its velocity.