Guest User

Untitled

a guest
Jul 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. // State.cs
  2.  
  3. public class State : ScriptableObject
  4. {
  5. public Transition transition;
  6. private bool canChangeState;
  7.  
  8. // Called each frame
  9. public void UpdateState (StateMachine _stateMachine)
  10. {
  11. CheckTransition(_stateMachine);
  12. }
  13.  
  14. private void CheckTransition (StateMachine _stateMachine)
  15. {
  16. if (transition != null)
  17. {
  18. bool decisionSucceeded = transition.condition.Decide();
  19.  
  20. if (decisionSucceeded && canChangeState)
  21. {
  22. _stateMachine.ChangeState(transition.nextState);
  23. canChangeState = false;
  24. }
  25. }
  26. }
  27. }
Add Comment
Please, Sign In to add comment