- Home /
How to get the AI enemy character to play random audio clips over time?
How would I have maybe 6 or 7 audio clips play at random times from the enemy character? I'm trying to get it to say stuff like "Where'd he go?", "I see him!", etc. But it needs to have random time intervals between each clip. I studied the player footsteps script but I can't seem to adapt that to this problem.
Answer by Rasmus Schlnsen · Sep 26, 2010 at 03:40 PM
Check out Random.Random range function and AudioSource.PlayClipAtPoint.
I would suggest you map your files into an array and then pick an index with the Random.Range function.
Good luck!
You got my upvote anyway, but I'd usually suggest linking to the script reference when na$$anonymous$$g methods. Cheers.
Your answer
Follow this Question
Related Questions
Random Audio Clip Help 3 Answers
Random, 3d sound. 1 Answer
Can't select audio clip even though it's there 1 Answer
Start ambient audio tracks at random points? 2 Answers
Assign clip to audio source 1 Answer