Enable or disable collisions (ghost)

By default a character detects collisions and responds to that as expected like any dynamic rigid body. If for some reason this character needs to pass through objects then collisions must be disabled in some way. There are two ways you can achieve this:

  1. Disabling the collider component.

  2. Setting the character as kinematic

Disabling the collider component

The actor uses a ColliderComponent component which is a wrapper around a 2D/3D collider. Enabling/disabling this component will automatically enable/disable the collider.

CharacterActor.ColliderComponent.enabled = enableCollider;

Note that without a collider the physics engine won't include the body as part of the simulation. In other words, the character won't interact with other bodies in any way.

Setting the character as kinematic

Unlike a dynamic rigid body, a kinematic character is essentially considered by the physics engine as an infinite mass body that doesn't get affected by forces, meaning it can penetrate anything.

CharacterActor.IsKinematic = !enableCollisions;

Note that a kinematic rigid body IS part of the simulation, which means the body will be able to interact with other bodies and also trigger physics-related callbacks.

Last updated