Physics
The physics component is a core component that provides an entity with 3D physics. For further details on all properties associated with this component and how to use this component with scripting, please see the API documentation.
Properties
The physics component properties that are accessible through the inspector.
Body
A rigid body is a solid object that can experience forces but does not deform as a result. It is one of the following:
- 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 the children (representing the top and four legs) can each have a box collider that gets attached to the parent. Composite/compound physics geometry is generally 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 can be moved directly by setting the position of the attached entity.
Collider
Colliders provide physics geometry to a rigid body. It is one of the following, ordered from most to least computationally efficient:
- None - No collision geometry.
- Plane - An infinite plane aligned with the local yz-plane and normal in the local x-axis. It can only be used with kinematic rigid bodies.
- Sphere - A bounding sphere around the entity and its descendants.
- Box - A bounding box around the entity and its descendants.
- Convex - A convex hull around the entity and its descendants.
- Custom - A custom physics mesh generated by the external collider tool.
- Nonconvex - A triangle mesh for the entity and its descendants. It can 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. They can be used to represent pretty much any complex shape that has concavities. The custom colliders are typically more efficient and more stable than nonconvex triangle meshes. They can also be applied to dynamic rigid bodies, unlike the nonconvex type. See the custom physics collider page for more details.
Layer
The physics collision layer. If no collision layer is assigned, the rigid body will collide with all other rigid bodies by default. You can 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, which allows you to specify a row of the physics collision layer matrix. This matrix defines whether two layers can interact through collisions or not. See the API documentation site for more details.
Material
The physics material is used to calculate the contact properties for collisions. You can 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, allowing you to configure the material properties. Each material must have a unique name. Other properties include coefficients for static/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 and there are tolerances built into the meshes. Soft materials can also be used to increase stability by damping oscillations.
Mass
The mass of the rigid body. This property is hidden/ignored for the attached and kinematic body types. Note that kinematic bodies effectively have infinite mass.
Joints
The collection of dynamic physics joints. A joint constrains one or more degrees of freedom between two rigid bodies. It determines how two rigid bodies move relative to one another. Contraints are one of the following:
- 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.
- Fixed - Fully 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 (crease/curve) 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 selection. You can right click whilst hovering to negate the direction of the axis.
The prismatic and revolute joints can 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) that is automatically bound to the joint.
Advanced
The advanced properties 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 for the rigid body.
- Angular Damping - The angular damping 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 value-1
is used, ProtoTwin will automatically try to determine an appropriate contact offset based on the size of the graphics mesh. - Rest Offset - The distance from the surface of the collider at which objects come to a 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.