Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

OnTriggerEnter Not Fired?

Discussion in '2019.3 Beta' started by SSheng, Jul 30, 2019.

  1. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    577
    Hi!

    Could you guys also try this build out for me please https://beta.unity3d.com/download/2dc8f57a51b5/public_download.html? This is with the trigger-trigger patch, and also with the PhysX 4.1.1 (the latest released PhysX to date). PhysX release notes: https://gameworksdocs.nvidia.com/PhysX/4.1/release_notes.html. If looks good - opening up a PR to 2020.1 later this week (+ a backport to 2019.3). Thanks for your help.

    (Note: the version has not been bumped up since the last build shared in this thread)

    Anthony
     
  2. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    I have to wait for the 2020.1 version to test it. Hopefully you are able to push it soon
     
  3. SynapticBytes

    SynapticBytes

    Joined:
    Sep 26, 2019
    Posts:
    12
    It works fine on my two simple tests.
     
  4. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    863
    Looks good for me.
     
  5. hoesterey

    hoesterey

    Joined:
    Mar 19, 2010
    Posts:
    659
    Great! Excited to see this in!
     
  6. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    @yant is Unity 2019.3.0b8 Early Feedback the same as official beta 8?
     
  7. antwood

    antwood

    Joined:
    Mar 24, 2016
    Posts:
    4
    nope
     
    yant and konsic like this.
  8. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    any progress on the 2020.1 build?
     
  9. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    577
    Yes - I have the pull requests in the pipes for both 2020.1 and 2019.3. I'll be sharing more once I have dates or version ids.
     
  10. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    Does official beta 8 have your fix built in?
     
  11. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    Thanks. I'm desperate to test this on 2020! It's been a nightmare to adjust triggers and I keep finding more and more werid cases.
     
  12. JoNax97

    JoNax97

    Joined:
    Feb 4, 2016
    Posts:
    611
    Hey, I just wanted to know if this solution (changing internals of physX) will be healthy in the future. I mean someone from PhysX team said the removed trigger code path allowed them to refractor stuff. Will it not be problematic for keeping up with new versions?

    What will happen when a refractor or new feature comes, that is incompatible with the old code you've added again?
     
  13. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    577
    Fair question. There are three options I can point out from the top of my mind:
    (1) We don't upgrade to breaking changes
    (2) We fix the breaking changes until they go nice with what I did to return trigger-trigger
    (3) We stop using PhysX triggers at all, and rewrite our system based on contact detection
     
    brunocoimbra and JoNax97 like this.
  14. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    577
    Concerning PhysX upgrades - that may be out of topic here - it's never been a case that updating to a new version of PhysX was free in terms of effort spent on maintaining our API invariants. Every version was special to deal with, and I can't see how this change makes it different. We've never been using stock physx at all. Hope that makes sense.
     
    hoesterey, brunocoimbra and JoNax97 like this.
  15. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,438
    What approach do you think would cause the least issues long term?
     
  16. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    577
    Well, it's easiest to not upgrade at all, but that means we won't get any new fixes back-ported after a while too, so that's not feasible long-term really if we were to commit to maintaining PhysX. Personally, I believe we'll work out a solution based on (3), and that sounds like the way Pierre was advocating for. Not in the pipes yet.
     
    Peter77 and brunocoimbra like this.
  17. JoNax97

    JoNax97

    Joined:
    Feb 4, 2016
    Posts:
    611
    Thank you for the honest and detailed response. I, too, think that (3) is the right way going forward, and also think that is perfectly reasonable to revert the internal changes in order to alleviate immediate user pain. It was not my intention to imply otherwise.

    I was not aware that Unity deviated from stock physX, as I haven't used it I kinda assumed it was a straightforward wrapper.
     
    yant likes this.
  18. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    577
    Here is an update that the patch we tried in a custom build shared above will be part of Unity 2020.1.0a12. Dates for the 2019.3 backport are still TBD. Thanks for your help testing, much appreciated! Anthony
     
    SugoiDev and brunocoimbra like this.
  19. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    Thank you for your hard work. Please push this patch in beta9 next week if anyhow possible.
     
  20. DiegoR

    DiegoR

    Joined:
    Oct 31, 2012
    Posts:
    33
    @UT

    Can you, PLEASE, add this warming or note to the documentation of the trigger related events?

    There is nothing. The communication of UT with his community is lousy. It's not the first time I discovered something by the fourm that should be announced elsewhere. Just like the problems with Unity and High Sierra (related to APS) and now with Catalina (related to Android NDK). USE THE BLOG FOR SOMETHING USEFUL AND INFORM!
     
  21. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    This is beta. It's not meant for any kind of production. Docs is for official release.
     
    brunocoimbra likes this.
  22. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    577
    And here is another note to say the trigger patch will be shipped as part of 2019.3.0b10. Thanks again to everyone involved, and please do keep me in the loop regarding physics issues breaking your projects.
     
    Seith, Mnemotic, hoesterey and 2 others like this.
  23. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    Thank you for the notice. Now I can adjust the schedule.
     
  24. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
    any idea for which 2020.1 version will it be?
     
  25. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    From Unity 2020.1.0a12.
     
  26. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,739
  27. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    863
    @yant a little bit off topic, but does collision resolution somehow depends on frame rate? I am using Physics Scene and manually calling Simulate. And I've noticed that if I call Simulate like 20 times a frame (my implementation of time warp) all collisions become unstable and give unpredictable results (huge forces and velocities as result). While using it with normal rates (2-3 per frame) everything works as expected. I am applying all forces before calling physicsScene,Simulate() and calling it with fixed timeStamp (0.02). I can't find anything that can cause such results. So the second question: are there anything I should pay attention when implementing "time warp" with the Physics scene?
     
    konsic likes this.
  28. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    863
    Nevermind, I found the issue. Due to precision error sometimes very small number (like 1e-09) was passed to physicsScene.Simulate(); instead the fixed timestamp, which caused these problems.
     
  29. Rukas90

    Rukas90

    Joined:
    Sep 20, 2015
    Posts:
    167
    Same issue in Unity 2019.2.11f1
     
  30. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    577
    Excuse me, but what issue in 2019.2? This thread originally was about a deprecated feature in PhysX 4.1 upgrade to which only started to be available in 2019.3.
     
  31. Rukas90

    Rukas90

    Joined:
    Sep 20, 2015
    Posts:
    167
    Hey there, oh sorry my mistake then.. I thought this thread was about a bug issue.
    I have some weird issues with OnTrigger events. I have a script and a sphere collider (with IsTrigger checked) attached onto the game object, but when other game objects with colliders attached on them enter the sphere collider the OnTriggerEnter method is not fired.

    I never had this type of problem before, so not sure what's the issue. I looked up and down and can't figure it out what could be causing this, so thought maybe this was a bug.
     
  32. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    I have the same issue. How fast is you sphere collider with trigger moving? I checked Continous detection but the weird part sometimes trigger gets released, sometimes not.
     
  33. Rukas90

    Rukas90

    Joined:
    Sep 20, 2015
    Posts:
    167
    The object with Sphere collider is a turret, so it does not move, only the objects that enter the Sphere collider (enemies), so Sphere collider is like a sensor for the turret, but some enemies move really slow and I tried to move the object manually into the trigger, just doesn't detect anything :confused:
    My enemy objects are without rigidbody component as I'm making a game for mobile, would really slow down the frame rate I think, a lot of rigidbodies, although I tried with rigidbody as well, just to check, it didn't work either. :/
     
  34. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    558
    kinematic rigidbody + static triggers should work (as long as you move the objects through rigidbody, not transform)

    otherwise if you don't have many spheres you can do sphere casts instead of triggers

    (or use DOTS physics)
     
  35. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    677
    Any moving collider should have a Rigidbody, otherwise it will be treated as a static collider (and two static colliders doesn't send trigger messages). Attach a Rigidbody and mark as kinematic.

    Also, please keep that thread focused on the main topic, create a separated thread if you need further help on that. We are in the 2019.3 Beta threads, any issues with previous versions doesn't belong here.
     
  36. Seith

    Seith

    Joined:
    Nov 3, 2012
    Posts:
    755
    Hi @yant, just writing in to say the trigger-to-trigger detection behaviour is indeed back to normal with 2019.3b10. Thanks for realizing the importance if this and reacting so quickly!
     
    brunocoimbra and yant like this.
  37. kdubnz

    kdubnz

    Joined:
    Apr 19, 2014
    Posts:
    177
    Is it expected GameObjects without trigger colliders should call the OnTriggerEnter method in that object.?
    This is happening.

    Regards,
     

    Attached Files:

  38. kdubnz

    kdubnz

    Joined:
    Apr 19, 2014
    Posts:
    177
    I've been told that OnTriggerEnter in scripts on nonTrigger objects have been catching messages for a considerable period of time.
    Is this the designed behaviour ?
    If so, the documentation should be revised.

    The docs https://docs.unity3d.com/2019.3/Documentation/Manual/CollidersOverview.html
    quote :

    >> The scripting system can detect when collisions occur and initiate actions using the OnCollisionEnter function. However, you can also use the physics engine simply to detect when one collider enters the space of another without creating a collision. A collider configured as a Trigger (using the Is Trigger property) does not behave as a solid object and will simply allow other colliders to pass through. When a collider enters its space, a trigger will call the OnTriggerEnter function on the trigger object’s scripts.

    Regards,