using System.Collections; using System.Collections.Generic; using UnityEngine; public class AttackState : State { [SerializeField] private State idleState; [SerializeField] private Transform bulletSpawnPos; protected override void EnterState() { Agent.AgentAnimator.SetAnimationTo(AnimationType.Attack); Invoke("ThrowBullet",0.26f); Invoke("BackToIdle",0.45f); } private void BackToIdle() { Agent.TransitionTo(idleState); } private void ThrowBullet() { GameObject bullet = Agent.ObjectPool.GetFromPool(); if (bullet != null) { bullet.gameObject.SetActive(true); bullet.transform.position = bulletSpawnPos.position; Rigidbody2D bulletRb = bullet.GetComponent(); bulletRb.velocity = new Vector2(10,bulletRb.velocity.y); } else { Debug.Log("Bullet could not be created or empty"); } } }