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

Ontriggerstay called late?(sorted)

Discussion in 'Scripting' started by tawdry, Feb 13, 2015.

  1. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    I have a script which first has ontriggerstay then update but the update is executed first is this correct?
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    If you say it's correct then it's correct.
     
  3. gamer_boy_81

    gamer_boy_81

    Joined:
    Jun 13, 2014
    Posts:
    169
    Check out the execution order in the flowchart :

    http://docs.unity3d.com/Manual/ExecutionOrder.html

    From the chart we can see that onTriggerXXX is called first and then Update, however
    FixedUpdate call may happen at different rates between frames, so maybe this is
    why you are seeing the Update called first.
     
  4. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    Don't have a fixed update it gpes straight to update then only calls ontrigger i put a debug right at the start of ontrigger and its called only after i get the error in update for there been a null reference due to ontriggerstay not running yet.
     
  5. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    I think his point is that OnTrigger* is dependent on the fidelity of your physics simulation (ie - what your fixed time step is set to). It might be listed first in the order but your physics might not be updating on that frame.
     
  6. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    what your fixed time step is set to) How do u alter this value?
     
  7. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
  8. tawdry

    tawdry

    Joined:
    Sep 3, 2014
    Posts:
    1,356
    cool thx ill play around with it