Urho.Physics Namespace

Rigid body physics simulation.

Remarks

To use the physics system in your program, you must first create a PhysicsWorld component in your scene.  A RigidBody component can be attached to a node to give it a physical properties like giving it a mass, friction, restitution and linear and angular velocities.   

You use a CollisionShape to define the physics of the collision geometry.   There are several built-in types defined in the ShapeType enumeration.

Constraints connect two rigid bodies together or a rigid body to a static point in the world.

Movement and Collision

Both a RigidBody and a CollisionShape are needed in a scene node to behave physically. You can add several collision shapes to a node to create compound shapes.

For more information, see the documentation for RigidBody

Physics Simulation Rate

The physics simulation has its own fixed update rate, which by default is 60Hz.

When the rendering framerate is higher than the physics update rate, physics motion is interpolated so that it always appears smooth. The update rate can be changed via the PhysicsWorld.Fps property. The physics update rate also determines the frequency of fixed timestep scene logic updates.

Hard limit for physics steps per frame or adaptive timestep can be configured with PhysicsWorld.MaxSubSteps property. These can help to prevent a "spiral of death" due to the CPU being unable to handle the physics load. However, note that using either can lead to time slowing down (when steps are limited) or inconsistent physics behavior (when using adaptive step.)

Classes

TypeReason
CollisionDataContains the information about a physics collision event.
CollisionEventMode Rigid body collision event signaling mode.
CollisionShapePhysics collision shape component.
Constraint Physics constraint component. Connects two rigid bodies together, or one rigid body to a static point.
ConstraintType Supported constraint types.
PhysicsCollisionEndEventArgsEvent arguments for the PhysicsWorld's PhysicsCollisionEnd event
PhysicsCollisionEventArgsEvent arguments for the PhysicsWorld's PhysicsCollision event
PhysicsCollisionStartEventArgsEvent arguments for the PhysicsWorld's PhysicsCollisionStart event
PhysicsPostStepEventArgsEvent arguments for the PhysicsWorld's PhysicsPostStep event
PhysicsPreStepEventArgsEvent arguments for the PhysicsWorld's PhysicsPreStep event.
PhysicsRaycastResultPhysics raycast hit
PhysicsWorld Physics simulation world component. Should be added only to the root scene node.
RigidBody Physics rigid body component.
ShapeType Collision shape type.