collider_position
The position of a collider represents its location (translation) in 2D or 3D world-space as well as its orientation (rotation).
Transform
component.
Please read carefully the paragraph after the next example. It explains how the collider position (and the action of setting this position) behaves differently when it is attached to a rigid-body.
It is possible to set this position when the collider is created or after its creation:
- Example 2D
- Example 3D
<load path='/2d/rust/examples/rs_colliders2.rs' marker='Position1' />
<load path='/2d/rust/examples/rs_colliders2.rs' marker='Position2' />
<load path='/3d/rust/examples/rs_colliders3.rs' marker='Position1' />
<load path='/3d/rust/examples/rs_colliders3.rs' marker='Position2' />
- Example 2D
- Example 3D
<load path='/2d/bevy/examples/colliders2.rs' marker='Position1' />
<load path='/2d/bevy/examples/colliders2.rs' marker='Position2' />
<load path='/3d/bevy/examples/colliders3.rs' marker='Position1' />
<load path='/3d/bevy/examples/colliders3.rs' marker='Position2' />
- Example 2D
- Example 3D
<load path='/2d/javascript/src/snippets/colliders.ts' marker='Position1' />
<load path='/2d/javascript/src/snippets/colliders.ts' marker='Position2' />
<load path='/3d/javascript/src/snippets/colliders.ts' marker='Position1' />
<load path='/3d/javascript/src/snippets/colliders.ts' marker='Position2' />
If a collider is attached to a rigid-body, its position is automatically updated by the physics pipeline when a rigid-body is moved by the physics pipeline. If a change to the rigid-body position is made by the user then the collider position will be updated during the next timestep.
Transform
of a collider attached to a rigid-body will modify the position of the
collider relative to the rigid-body it is attached to:- Example 2D
- Example 3D
<load path='/2d/rust/examples/rs_colliders2.rs' marker='Position3' />
<load path='/2d/rust/examples/rs_colliders2.rs' marker='Position4' />
<load path='/3d/rust/examples/rs_colliders3.rs' marker='Position3' />
<load path='/3d/rust/examples/rs_colliders3.rs' marker='Position4' />
- Example 2D
- Example 3D
<load path='/2d/bevy/examples/colliders2.rs' marker='Position3' />
<load path='/3d/bevy/examples/colliders3.rs' marker='Position3' />
- Example 2D
- Example 3D
<load path='/2d/javascript/src/snippets/colliders.ts' marker='Position3' />
<load path='/2d/javascript/src/snippets/colliders.ts' marker='Position4' />
<load path='/3d/javascript/src/snippets/colliders.ts' marker='Position3' />
<load path='/3d/javascript/src/snippets/colliders.ts' marker='Position4' />