public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { _timePassed += Time.deltaTime; if (_timePassed > stateInfo.length / 3 && !_shootDone) { _weapon.Shoot(GameObject.FindGameObjectWithTag("Player").transform.position); _shootDone = true; } }
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { if (!_componentsCached) { _weapon = animator.gameObject.GetComponentInChildren <SingleShootingWeapon>(); _playerTransform = GameObject.FindGameObjectWithTag("Player").transform; _componentsCached = true; } _weapon.Shoot(_playerTransform.position); }