Search Unity

Bug CharacterController not triggering OnTriggerStay AT ALL!

Discussion in 'Physics' started by CaseyHofland, May 9, 2023.

  1. CaseyHofland

    CaseyHofland

    Joined:
    Mar 18, 2016
    Posts:
    613
    We use a CharacterController for our characters movement and have death triggers placed in places like ravines, gaps, standard stuff. They're super simple:
    Code (CSharp):
    1. public class DeathTrigger : MonoBehaviour
    2. {
    3.     public Transform resetPosition;
    4.  
    5.     private void OnTriggerStay(Collider other)
    6.     {
    7.         Debug.Log("I'm Triggered >:C");
    8.         if (other.CompareTag("Player"))
    9.         {
    10.             other.transform.SetPositionAndRotation(resetPosition.position, resetPosition.rotation);
    11.         }
    12.     }
    13. }
    Even so, sometimes these don't get triggered, at all. You can run, jump, sneeze, you have full control and they won't reset your position!




    That was tldr, now let me show you my homework:

    The character just has a character controller on it, the death triggers we're testing with now have a kinematic rigidbody, and I've set Contact Pairs Mode to "Enable Kinematic Kinematic Pairs".

    According to the collision matrix, triggers should be activated anyway:
    Yes.png

    Given, that's for Kinematic Rigidbodies, but I would expect it to work the same for the CharacterController.

    The worst part is: most of the time it works. But if it breaks, for whatever reason (literally without cause, you can restart 50 times and get random results), your enjoyment is ruined.

    What
    The
    Hell?!

    This issue crops up in other places too, with OnTriggerEnter triggering constantly and OnTriggerExit never triggering, but the above is the most blatant example of brokenness we have.

    Should we just abandon CharacterController and use Rigidbodies? That would be a big rewrite for us but... it's a character controller. It has to work.
     
    Last edited: May 9, 2023