x


Audio Source AI Attractor

Hi everyone

Well right now I am making a Zombie Game and i was wondering how i would make it so that zombies in range of a certain audio source would move towards it, help would be greatly appreciated

more ▼

asked Nov 27 '09 at 05:29 PM

Will gravatar image

Will
408 8 10 19

(comments are locked)
10|3000 characters needed characters left

2 answers: sort newest

This is related to audio sources only in that's the way you conceive it as a human being. From an abstract standpoint, what you need to do is figure out which objects a zombie would be attracted to (in this case likely a player, a gun, a firecracker, etc) then evaluate proximity of the zombie unit to an object of this class.

There are many ways to do it, from a proximity database (look up Octrees if you'll have a ton of these) to simply using a trigger for detecting when the object gets close enough to a zombie.

As an example, you could take a look at the radar examples on UnitySteer, or for a much more trivial case (on an older, likely outdated article) at Proximity detection with triggers.

more ▼

answered Nov 27 '09 at 05:45 PM

Ricardo gravatar image

Ricardo
5.2k 20 32 96

(comments are locked)
10|3000 characters needed characters left

A simple solution is making a custom PlayOneShot function that besides playing the audio at point in space also notifies zombies in range. A simple way to do it is placing zombies and chars that must be able to hear in a special layer and call in the MyPlayOneShot:

foundList = Physics.OverlapSphere(*pos_of_audio*, *radius_related_to_loudness*, *hearingLayer*)

and go over the returned foundList array and send message to gameobjects with the position of the sound.

more ▼

answered Nov 28 '09 at 02:17 AM

Jaap Kreijkamp gravatar image

Jaap Kreijkamp
6.4k 20 26 70

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x957
x39
x5

asked: Nov 27 '09 at 05:29 PM

Seen: 1452 times

Last Updated: Dec 08 '09 at 12:15 AM