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

executing code after all FixedUpdate calls every fixed frame

Discussion in 'Scripting' started by firas darwiche, Mar 20, 2007.

  1. firas darwiche

    firas darwiche

    Joined:
    Oct 4, 2006
    Posts:
    130
    I have a piece of code that I want executed every fixed frame. The natural place for it is obviously in FixedUpdate. however, I want it executed the last on every fixed frame. i.e. if it is in a FixedUpdate, I want this to be the last FixedUpdate to execute.

    so in short, is there a way to execute a piece of code every fixed frame after all FixedUpdate methods are called (or before any FixedUpdate methods are called)

    if there were a LateFixedUpdate the problem I'm posting here would have been solved.

    thanx to u all,
    Firas
     
  2. mindlace

    mindlace

    Joined:
    Mar 31, 2007
    Posts:
    24
    My suggestion would be to have a "timer" coroutine that sets a variable to True and yields WaitForFixedUpdate , then put the code you want to run after the FixedUpdate in LateUpdate inside a check to see if the variable is true; then have the LateUpdate function re-set the boolean to False.