public void OnHearImpactSound(Transform noisyObject) { objectsInvestigating.Push(noisyObject); if (stateMachine.IsInState(typeof(SpottedObjectState))) { return; } Alert(); if (stateMachine.IsInState(typeof(InvestigatingSoundState))) { stateMachine.Hesitate(); CompareDistancesToInvestigate(noisyObject); } else { stateMachine.SwitchState(new InvestigatingSoundState(stateMachine)); } }