Search Unity

OnTriggerStay stopped work in 5.2.0f3 version

Discussion in 'Physics' started by Tiago-CC, Sep 9, 2015.

  1. Tiago-CC

    Tiago-CC

    Joined:
    Oct 30, 2014
    Posts:
    7
    I had an issue with Update for 5.2.0f3 version .
    OnTriggerEnter and OnTriggerExit work but OnTriggerStay stopped work on all scripts.
    More people had this problem with the Update?
     
  2. Tiago-CC

    Tiago-CC

    Joined:
    Oct 30, 2014
    Posts:
    7
    Well, researching the subject , I found this bug that was reported as fixed in version 5.1.3 .
    ( 703 073 ) - Physics : Fixed an issue where OnTriggerStay would not be called on children in compound colliders .
    However seems to be right back in version 5.2.0f3 .
    I auditioned and actually when the problem appears when the script and collider are in GameObject child and has a parent with another collider . In the parent OnTriggerStay works, but not in the child .
     
  3. robotloveskitty

    robotloveskitty

    Joined:
    Nov 15, 2011
    Posts:
    2
    This bug has broken multiple projects for us.

    I was experimenting and thinking about how Rigidbodies and stuff like that worked and thought to add a small script to the Parent object where the Rigidbody was located. I added a OnTriggerStay() function with nothing in it... suddenly all child triggers started working.

    A quick work around for anyone with this issue.
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Stay is pretty much awful performance so in the meantime it may well be better for you to refactor to using flags to see if something is inside by using OnEnter/Exit.

    You would still be helping yourself and everyone if you fire a bug report though :)
     
  5. adamgryu

    adamgryu

    Joined:
    Mar 1, 2014
    Posts:
    188
    Just want to report that I also noticed this bug in the current release. We can create a workaround, but it would be nice to have it fixed!
     
  6. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Bug reports that have repro files get things fixed super quick, just saying :) forums are rarely a place where developers will investigate because the staff for QA are usually busy doing that job. And investigating bug reports from the report tool is what they do first.
     
  7. Tiago-CC

    Tiago-CC

    Joined:
    Oct 30, 2014
    Posts:
    7
    Bug report sent .
    https://fogbugz.unity3d.com/default.asp?726570_18vbh1t72r3sqqqb

    I made some changes , I spent a whole day to this, but I fixed my project. Insert the object's script a function to create a new GameObject , I copied the rotation and position of the parent object to this new object and changed the parent of the child for this new object. Then began a coroutine keeping the parent object at the position and rotation of the old parent .

    To everything there is a solution , but with a broken OnTriggerStay function had to add 3 more calls to each object of this type in the game. Besides having become much more complex .
     
    dreasgrech likes this.
  8. dcarrigg

    dcarrigg

    Joined:
    May 21, 2014
    Posts:
    24
    As a workaround: We added a OnTriggerStay call to the parent object, and the child object started getting the callbacks again.
     
    Komizart and Tiago-CC like this.
  9. Tiago-CC

    Tiago-CC

    Joined:
    Oct 30, 2014
    Posts:
    7
    Interesting !!!
    I'll test on my project and then put the result here.
     
  10. Tiago-CC

    Tiago-CC

    Joined:
    Oct 30, 2014
    Posts:
    7
    Great solution until they release a new version with the the bug fixed.

    Simply just call OnTriggerStay empty or not in parent , that OnTriggerStay role in the child also starts working .
    Thank you!
     
  11. nporaMep

    nporaMep

    Joined:
    Oct 31, 2014
    Posts:
    33
    I have kind of similar bug. It works in 5.1.0f3 and in same project it doesn't work in 5.2.0f3
    I have 2 custom layers Items and Sensors and Sensors are set to collide only with Items.
    Hierarchy "Default layer"->"Default layer"->"Sensors" works to collider with "Items".
    Hierarchy "Default layer"->"Default layer"->"Default layer"->"Sensors" doesn't collide with "Items".
    OnTriggerStay is never called for 2nd hierarchy, but is called for first.

    OnTriggerEnter/Exit works well.
     
    Last edited: Sep 14, 2015
  12. Komizart

    Komizart

    Joined:
    Nov 21, 2015
    Posts:
    6
    God bless you man! You are my hero!
     
  13. lavz24

    lavz24

    Joined:
    Mar 14, 2013
    Posts:
    45
    After upgrade 5.2.3f1 the physics doesnt work anymore. I have to 4.2.2p3 and Its work well
     
  14. Morineh

    Morineh

    Joined:
    Oct 28, 2015
    Posts:
    1
    Upgrading to 5.3 broke OnTriggerStay for me! Changing OnTriggerStay to OnTriggerEnter made it start doing something again, but the behavior of OnTriggerEnter isn't what I'm looking for, which is why I wasn't using it.

    More details:

    My scene is a default flat plane with a character on it.

    On the top-most parent object of the character (Player) I have:
    A box collider (non trigger collider), so that I don't fall through the floor.
    A script that has OnTriggerStay in it. This code works correctly.

    On a child object (a foot) that is 7 objects deep from the parent I have:
    A box collider (trigger collider).
    A script that has OnTriggerStay in it. This seems to be only called temporarily.

    The two colliders on my character are always touching each other.

    Here is the code in the child object's (foot) script.

    public int testVar = 0;
    void OnTriggerStay(Collider col){
    Debug.Log(col.tag); // Important for debugging! Check console!
    switch (col.tag){
    case "SurfaceStone" : testVar = 0; break;
    case "SurfaceRug" : testVar = 1; break;
    case "SurfaceWood" : testVar = 2; break; }}

    When I start the game with my character on the plane,
    I get logs for about a second, and then it stops logging.
    I get 43 Debug logs and no more.
    They alternate between "Player" and "Untagged".
    After that, OnTriggerStay is never called again on that script,
    no matter what colliders I go through.
    Now, if I start the game with my character already in other trigger colliders
    with the tags "SurfaceStone" and so on, those are called like they're
    supposed to and then stop after about a second or about 59 logs.
    If I start the game in a trigger collider that is tagged "SurfaceRug", the testVar is 1
    and stays 1 and is never updated after about the first second of running the game.
     
    Last edited: Dec 8, 2015