Skip to main content

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.

Constructors​

MemberWhat it is
CharacterCollisionController()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

6 private and internal fields
MemberWhat it is
private Dictionary<Interactor, ColliderGroup> collidersMapMaps each hand's Interactor to the collider group that should ignore what it holds.
private CharacterCollisionController.CollidersToDisableWhenInteracting[] collidersToDisableWhenInteractingSerialized backing array for CollidersToDisableWhenInteractingList.
private float collisionEnableDelaySeconds to wait after letting go before collision comes back. Default 0.1.
private Dictionary<Interactor, Collider[]> disabledCacheThe pickup colliders most recently ignored, per interactor, so they can be restored.
private Dictionary<Interactor, Coroutine> enablingCoroutinesPending re-enable coroutines per interactor, so a new grab can cancel them.
private bool isStartedTrue once PlayerSet has run.

Properties​

MemberWhat it is
CharacterCollisionController.CollidersToDisableWhenInteracting[] CollidersToDisableWhenInteractingList { get; }The configured pairs of hand controller and collider group to ignore while that hand holds something.

Methods​

MemberWhat it is
override void FixedUpdateCharacterComponent()Throws NotImplementedException. Don't call it.
8 private and internal methods
MemberWhat 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.