CharacterCollisionController
A class in Root.Township, Alta.Character.
On the local player, stops the player's own colliders from hitting a pickup while a hand holds it, and turns collision back on a short time after it is let go.
- Listed in Players and characters
- Inherits or implements
CharacterComponentController - Derived types
CharacterCollisionControllerHelper - Nested types
CollidersToDisableWhenInteracting
Constructors
| Member | What it is |
|---|---|
CharacterCollisionController() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
6 private and internal fields
| Member | What it is |
|---|---|
private Dictionary<Interactor, ColliderGroup> collidersMap | Maps each hand's Interactor to the collider group that should ignore what it holds. |
private CharacterCollisionController.CollidersToDisableWhenInteracting[] collidersToDisableWhenInteracting | Serialized backing array for CollidersToDisableWhenInteractingList. |
private float collisionEnableDelay | Seconds to wait after letting go before collision comes back. Default 0.1. |
private Dictionary<Interactor, Collider[]> disabledCache | The pickup colliders most recently ignored, per interactor, so they can be restored. |
private Dictionary<Interactor, Coroutine> enablingCoroutines | Pending re-enable coroutines per interactor, so a new grab can cancel them. |
private bool isStarted | True once PlayerSet has run. |
Properties
| Member | What it is |
|---|---|
CharacterCollisionController.CollidersToDisableWhenInteracting[] CollidersToDisableWhenInteractingList { get; } | The configured pairs of hand controller and collider group to ignore while that hand holds something. |
Methods
| Member | What it is |
|---|---|
override void FixedUpdateCharacterComponent() | Throws NotImplementedException. Don't call it. |
8 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Subscribes to PlayerController.LinkedToLocalPlayer so setup waits until the local player exists. |
private IEnumerator DelaySetColliders(float delay, Interactor interactor, bool isIgnoring, Pickup pickup) (iterator) | Coroutine: after the delay, turns collision back on unless the pickup is still held by either hand or is a crafted child. |
private void DisableColliders(Interactor interactor, Interactable interactable) | Runs before a hand starts holding a pickup: cancels any pending re-enable and makes the group ignore the pickup's colliders. |
private void EnableColliders(Interactor interactor, Interactable interactable) | Runs when a hand lets go of a pickup: starts the delayed re-enable of collision. |
private void OnDisable() | Unsubscribes from the hands' interaction events. |
private void OnEnable() | Once set up, subscribes to each hand's PreInteractionStarted and InteractionEnded events. |
private void PlayerSet() | Called once the local player is linked: builds the interactor to collider group map and subscribes to the events. |
private void SetColliders(Interactor interactor, bool isIgnoring) | Turns Physics.IgnoreCollision on or off between the hand's collider group and the cached pickup colliders. |