Search Unity

Character should not collide with trigger

Discussion in 'Physics for ECS' started by filod, Dec 16, 2019.

  1. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    224
    Do we have a workaround?
     
  2. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    That depends. If you don't need trigger events from your character, which is unlikely, you can just setup the collision filters so that character ignores triggers.

    However, if you need trigger events, we have a workaround, but it's not very simple to share. Will try to come up with something shareable.
     
  3. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    224
    without Trigger events many gameplay logic can't be achieved (deadzone, door switch, etc.), so i'm very confused about this default behaviour.
    i'd like to see your sharing, Thx very much.
     
  4. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Yeah, it's not designed to work like that, it's just an issue that will be fixed soon.
     
    filod likes this.
  5. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    224
    Also i'd like to point out another strange behaviour is that character will not fire collision event either (mostly) because of SkinWidth, was this on purpose or a bug too?
     
  6. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    Collision events are only going to be raised when the likes of a dynamic body is flying at the character and inter-penetrations occur. The rest of the time the character controller code is trying to stop the character from getting into an interpenetrating state in the first place, and is handled collision information independently from the solver.

    So, one perspective is that collisions are collision and the CC should be raising collision events. The other perspecitive is that the CC contacts handled by the simplex solver should be considered different from the interpenetrating contacts handled by the general solver.

    Its sounds like the former is your expectation and the latter is the current design? I do think the two sets of collision information are fundamental different.

    What is your higher-level need? Rather, than trying to combine the internal CC collisions with the general simulaiton collision list, if the CC exposed the internal collision it resolves would that cover your need?
     
  7. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    224
    agreed, but my need is very simple&common, just want to play a SFX/VFX when Character land on ground. KCC provide something called OnGroundHit, also something like OnMovementHit would be helpful too (e.g. place hand on the wall).
    i think exposed the internal collision would be a good way to extend current functionality of CC.
     
  8. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    224
    @petarmHavok can we have that workaround now? or some guide so i can deal with it myself?
     
  9. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    I'm preparing the workaround, sorry for the delay.
     
    filod and Flipps like this.
  10. Flipps

    Flipps

    Joined:
    Jul 30, 2019
    Posts:
    51
    Also really interested in this :)
     
  11. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Attached you can find the changes to character controller which should result in not colliding with triggers, and also raising trigger events. It is probably a little too complicated, so I'll look more into the proper fix.

    Let me know if it works for you!
     

    Attached Files:

    Flipps and filod like this.
  12. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    224
    works quite well, thx very much!
     
    petarmHavok likes this.
  13. Flipps

    Flipps

    Joined:
    Jul 30, 2019
    Posts:
    51
    Big thanks for the fix! At first I forgot to add the PhysicsVelocity component to the character and wondered why the trigger event is not firing. But now everything works really well.
     
    petarmHavok likes this.
  14. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Thank you for trying out and reporting issues!
     
  15. petarmHavok

    petarmHavok

    Joined:
    Nov 20, 2018
    Posts:
    461
    Just a small update, the line 155
    m_lastColliderKey = new ColliderKey();​
    should actually be
    m_lastColliderKey = ColliderKey.Empty;​

    I've attached the updated code in case someone else needs it.
     

    Attached Files: