State

The State node is node to be used to make StateMachine.

The State node can have one or many events and nodes.

to add a events double click the state to edit the StateNode and right click on canvas > Add Event > and select available events

Available events:

  • On Enter called on state enter.
  • On Exit called on state exit.
  • Update is called every frame, if the MonoBehaviour is enabled and if state is running.
  • FixedUpdate is called every fixed framerate frame, if the MonoBehaviour is enabled and if state is running.
  • LateUpdate is called every frame, if the Behaviour is enabled and if state is running.
  • OnApplicationFocus called when the player gets or loses focus and state is running.
  • OnApplicationPause called when the player pauses and if state is running.
  • OnApplicationQuit called before the application is quit and if state is running.
  • OnBecameInvisible is called when the renderer is no longer visible by any camera and if state is running.
  • OnBecameVisibleis called when the renderer became visible by any camera and if state is running.
  • OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider and if state is running.
  • OnCollisionEnter2D called when an incoming collider makes contact with this object’s collider (2D physics only) and if state is running.
  • OnCollisionExitis called when this collider/rigidbody has stopped touching another rigidbody/collider and if state is running.
  • OnCollisionExit2D Sent when a collider on another object stops touching this object’s collider (2D physics only) and if state is running.
  • OnCollisionStay is called once per frame for every collider/rigidbody that is touching rigidbody/collider and if state is running.
  • OnCollisionStay2D called each frame where a collider on another object is touching this object’s collider (2D physics only) and if state is running.
  • OnDestroy is called when the MonoBehaviour will be destroyed and if state is running.
  • OnDisable is called when the behaviour becomes disabled () or inactive and if state is running.
  • OnEnable is called when the object becomes enabled and active and if state is running.
  • OnGUI is called for rendering and handling GUI events and if state is running.
  • OnMouseDown is called when the user has pressed the mouse button while over the GUIElement or Collider and if state is running.
  • OnMouseDrag is called when the user has clicked on a GUIElement or Collider and is still holding down the mouse and if state is running.
  • OnMouseEnter Called when the mouse enters the GUIElement or Collider and if state is running.
  • OnMouseExit Called when the mouse is not any longer over the GUIElement or Collider and if state is running.
  • OnMouseOver Called every frame while the mouse is over the GUIElement or Collider and if state is running.
  • OnMouseUp is called when the user has released the mouse button and if state is running.
  • OnMouseUpAsButton is only called when the mouse is released over the same GUIElement or Collider as it was pressed and if state is running.
  • OnPostRender is called after a camera finished rendering the scene and if state is running.
  • OnPreCull is called before a camera culls the scene and if state is running.
  • OnPreRender is called before a camera starts rendering the scene and if state is running.
  • OnRenderObject is called after camera has rendered the scene and if state is running.
  • OnTriggerEnter is called when the Collider other enters the trigger and if state is running.
  • OnTriggerEnter2D Sent when another object enters a trigger collider attached to this object (2D physics only) and if state is running.
  • OnTriggerExit is called when the Collider other has stopped touching the trigger and if state is running.
  • OnTriggerExit2D Sent when another object leaves a trigger collider attached to this object (2D physics only) and if state is running.
  • OnTriggerStay is called once per frame for every Collider other that is touching the trigger and if state is running.
  • OnTriggerStay2D Sent each frame where another object is within a trigger collider attached to this object (2D physics only) and if state is running.
  • OnWillRenderObject is called once for each camera if the object is visible and if state is running.

The State node have a transition which you can add by right click on node header > Add New Transition > and select available transition.

Available transitions:

  • Condition  finish when the condition is true.
  • OnApplicationFocus finish when the player gets or loses focus.
  • OnApplicationPause finish when the player pauses.
  • OnApplicationQuit finish before the application is quit.
  • OnBecameInvisible finish when the renderer is no longer visible by any camera.
  • OnBecameVisible finish when the renderer became visible by any camera.
  • OnCollisionEnter finish when this collider/rigidbody has begun touching another rigidbody/collider.
  • OnCollisionEnter2D finish when an incoming collider makes contact with this object’s collider (2D physics only).
  • OnCollisionExit finish when this collider/rigidbody has stopped touching another rigidbody/collider.
  • OnCollisionExit2D finish  when a collider on another object stops touching this object’s collider (2D physics only).
  • OnCollisionStay finish when collider/rigidbody that is touching rigidbody/collider and if state is running.
  • OnCollisionStay2D finish whena collider on another object is touching this object’s collider (2D physics only).
  • OnDestroy finish when the MonoBehaviour will be destroyed.
  • OnDisable finish when the behaviour becomes disabled () or inactive.
  • OnEnable finish when the object becomes enabled and active.
  • OnMouseDown finish when the user has pressed the mouse button while over the GUIElement or Collider.
  • OnMouseDrag finish when the user has clicked on a GUIElement or Collider and is still holding down the mouse.
  • OnMouseEnter finish when the mouse enters the GUIElement or Collider.
  • OnMouseExit finish when the mouse is not any longer over the GUIElement or Collider.
  • OnMouseOver finish every frame while the mouse is over the GUIElement or Collider.
  • OnMouseUp finish when the user has released the mouse button.
  • OnMouseUpAsButton finish when the mouse is released over the same GUIElement or Collider as it was pressed.
  • OnTimerElapsed finish when the given times is reach.
  • OnTriggerEnter finish when the Collider other enters the trigger.
  • OnTriggerEnter2D finish when another object enters a trigger collider attached to this object (2D physics only).
  • OnTriggerExit finish when the Collider other has stopped touching the trigger.
  • OnTriggerExit2D finish when another object leaves a trigger collider attached to this object (2D physics only).
  • OnTriggerStay finish once per frame for every Collider other that is touching the trigger.
  • OnTriggerStay2D  finish when another object is within a trigger collider attached to this object (2D physics only).
Was this helpful to you?

Leave a Reply

Your email address will not be published. Required fields are marked *