- Home /
How can I make my enemy detect and Run towards sound?
I am making a Horror Game and I need my Enemy to Run Towards a specific sound (e.x. I open a door and i make noise, enemy detects the sound and Runs towards that door.).
sorry for my bad English ;)
Comment
Answer by Magso · Jan 12, 2019 at 04:44 PM
If your playing the audio from a script, create a gameobject variable for the enemy and add something like
audioSource.PlayOneShot(sound, 1F);
enemy.GetComponent<script>.placetorun = gameObject.transform.position;
//or for the in built navigation.
agent.SetDestination(gameObject.transform.position);
Your answer
![](https://koobas.hobune.stream/wayback/20220612185625im_/https://answers.unity.com/themes/thub/images/avi.jpg)