public void TryShoot(ZombieAI ai) { float currentTime = Time.time; MoveForward(0); state = zmmBodyState.Firing; facingLeft = ai.transition > 0 ? true : false; if (currentTime - lastShootTime > shootInterval) { lastShootTime = currentTime; if (ShootEvent != null) { ShootEvent(); // Fire the "ShootEvent" event. ai.OnDamage(1); } } }