Jump to content

What happens to OnUpdate when switching states?


leron9999

Recommended Posts

Hi guys. I've been playing around with states recently, and I was wondering: what happens to an OnUpdate() event that has yet to be called when switching to a new state?

 

For example:

State sampleA
   Event OnBeginState()
    RegisterForSingleUpdate(300)
   EndEvent
   
   Event OnUpdate()
    ;Do something
   EndEvent

   Event OnHit(...)
    GoToState("sampleB")
   EndEvent
   
EndState

State sampleB
;Do something
EndState

What happens to the dangling register if the event OnUpdate() if OnHit is called first (meaning it is never called)? Does it get unloaded/unregistered automatically since it's a single update?

Link to comment
Share on other sites

Hi guys. I've been playing around with states recently, and I was wondering: what happens to an OnUpdate() event that has yet to be called when switching to a new state?

 

For example:

State sampleA
   Event OnBeginState()
    RegisterForSingleUpdate(300)
   EndEvent
   
   Event OnUpdate()
    ;Do something
   EndEvent

   Event OnHit(...)
    GoToState("sampleB")
   EndEvent
   
EndState

State sampleB
;Do something
EndState

What happens to the dangling register if the event OnUpdate() if OnHit is called first (meaning it is never called)? Does it get unloaded/unregistered automatically since it's a single update?

 

The OnUpdate() will still be called from the new state, so it will not unregister automatically, and I am not sure using a OnEndState() with UnregisterForUpdate() actually works for Single Updates...

 

There's a talk page on the Wikia which talks about this issue: Talk:State Reference

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...