Contents

mode

The behavioral mode that controls the way the physics body moves and interacts with other physics bodies in a simulation.

Declaration

var mode: PhysicsBodyMode

Discussion

The property’s default value is PhysicsBodyMode.dynamic, which means the physics body responds to forces and can collide with all other physics bodies in the simulation.

To configure the physics body so that an entity can move around the simulation without reacting to forces, set the property to PhysicsBodyMode.kinematic. Apps typically use kinematic mode for entities the app programmatically controls, such as in response to a control or a person’s interaction. For entities that don’t need to move at all, set its physics body’s mode to PhysicsBodyMode.static.

Physics bodies in static or kinematic mode can’t collide with other physics bodies with either mode, by default. Optionally, you can add collision support for entities that have a physics body in either static or kinematic mode by adding a PhysicsSimulationComponent to an entity that’s a common ancestor to the entities you want to collide. Then you can set PhysicsSimulationComponent.CollisionOptions to your preference.

You can change the mode of an entity’s physics body at any time, but changing it from static to another mode can affect your app’s performance because the transition to a non-static mode can trigger the simulation to rebuild its state.