For the complete documentation index, see llms.txt. This page is also available as Markdown.

Colliders

Summary

Shows how to modify colliders at runtime and sync the changes to clients using properties.

Collider scripts

Each collider has an associated server entity collider script. To get the list of colliders on an entity, use Scripts.GetAll<ksCollider>(). Once you have a reference to a collider script, you can modify its properties.

Enabling/disabling colliders at runtime

There are multiple different ways to enable/disable a collider, as described below.

  • ksCollider.IsEnabled - Enable or disable a collider by setting this. Disabled collider scripts remain attached to their entities, but no longer collider or generate events. It's best to use this is you are temporarily disabling the collider and will enable it again later.

  • Scripts.Attach and Scripts.Detach - Attach or detach collider scripts to add new colliders or completely remove colliders. It's best to detach a collider when you know you will never use it again.

  • ksCollider.CollisionFilter - You can change the collision filter on the collider to change which collision groups it collides with. Use this when you want to disable collisions with some objects, but still allow collisions with some other objects. See here for more information about using collision filters.

  • ksCollider.IsTrigger - Setting this to true will make the collider collide with nothing. Use this when you want to disable all collisions, but still want to receive overlap events for the collider.

  • ksCollider.IsSimulationCollider - Setting this to false will stop the collider from colliding or generating events, but it can still be found using scene queries if ksCollider.IsQueryCollider is true. Use this when you want to disable all collisions and events, but you want the collider to appear in scene queries (such as raycasts, sweeps, or overlaps).

Syncing collider changes

Modifications to collider scripts do not automatically sync to clients. If you are using a predictor on the client that predicts collisions such as the ksConvergingInputPredictor (this is the default for player-controlled entities that use input prediction), you will need to sync these changes yourself to make the collision prediction work properly. The following example shows how to use a property to sync collider enabled state.

Server Collider Controller Entity Script

Client Collider Controller Entity Script

Last updated