// Use this for initialization void Awake() { _controller = GetComponent <CharacterController2DTopDown>(); _animator = GetComponent <Animator>(); // listen to some events for illustration purposes _controller.onControllerCollidedEvent += onControllerCollider; _controller.onTriggerEnterEvent += onTriggerEnterEvent; _controller.onTriggerExitEvent += onTriggerExitEvent; }
void Awake() { //we set the controller _controller = GetComponent <CharacterController2DTopDown>(); //we set the animator if (SpriteAnimator != null) { _animator = SpriteAnimator.GetComponent <Animator> (); } if (_controller != null) { _controller.onControllerCollidedEvent += onControllerCollider; _controller.onTriggerEnterEvent += onTriggerEnterEvent; _controller.onTriggerExitEvent += onTriggerExitEvent; } _playerStateMachine = new StateMachine <PlayerController> (this); _playerStateMachine.SetCurrentState(MoveState.Instance); }