Search Unity

Why does box collider not trigger against Character Controller properly?

Discussion in 'Physics' started by cacotigon, Oct 27, 2019.

  1. cacotigon

    cacotigon

    Joined:
    Jun 12, 2015
    Posts:
    9
    I have a moving platform that is a primitive cube mesh with a kinematic rigid body and an additional box collider that is larger which is a "trigger". It is being moved side-to-side via rigidBody movePosition.



    When the player's character controller lands on the platform via OnTriggerEnter, it sets the Player's parent to the moving platform. My plan was that when OnTriggerExit was triggered, I would set the player's parent back to null and all would work properly.

    After landing, it gets parented properly and starts to move in sync with the platform, but then OnTriggerExit gets triggered (WHY???) and it detaches. Here's a video showing the console log file of what's going on. You can see that OnTriggerEnter and OnTriggerExit seem to continuously trigger despite the fact that the character controller is staying in place on top of the block.



    I've tried playing with Default Contact Offset, Skin Width, Collision detection from discrete to continuous speculation (since its kinematic), everything I can think of, nothing works.

    I also can't understand why the capsule collider seems to have to "penetrate" so deeply into the secondary box collider before OnTriggerEnter gets triggered either. You can see how far the capsule collider pushes into the box collider before it triggers.

    Look at how far the controller moves into the collider before it is triggered.




    I stumbled across a few posts that basically said messing around with parenting can screw up triggers, so I even tried creating a separate unparented independent GameObject with a box collider that would continuously center itself above the moving platform that would be responsible for parenting the player to the actual moving platform. So three objects, Player, MovingPlatform, and MovingCollider. Had the same exact issue.

    The video is actually the second attempt where I use the aforementioned three objects, PhysicsPlatform, PhysicsPlatformTrigger, and Player. Also if it's not immediately apparent by this point, ARGGHGHGHGHGGHGHGHGHGHGHGHGHG.
     
  2. cacotigon

    cacotigon

    Joined:
    Jun 12, 2015
    Posts:
    9
  3. cacotigon

    cacotigon

    Joined:
    Jun 12, 2015
    Posts:
    9
    The character controller / box collider issue has been filed as a bug with Unity.

    As far as handling moving platforms, I ended up solving the parenting issue by taking a different approach.