void Awake() { if (stateMachine == null) { stateMachine = new EnemyStateMachine(); } stateMachine.RegisterState(Object.Instantiate(wanderingState), this); stateMachine.RegisterState(Object.Instantiate(attackingState), this); rb = GetComponent <Rigidbody>(); }