Game Development Reference
In-Depth Information
How it works...
The SoundEmitterControl class is meant to define how much sound a moving char-
acter makes. It does this by measuring the distance traveled each frame, and translates it to
speed per second by dividing by the time-per-frame. It's been adapted slightly to work for
the free-flying camera used in the test case. That's why maxSpeed is set to 25 . It uses
maxSpeed to define how much noise the spatial is causing, on a scale of 0 to 1 .
In the AI control class, we use the sense() method to test whether the AI has heard any-
thing. It has a hearingRange field, with the range falling in a linear fashion from the
location of the AI. Outside this range, no sound would be detected by the AI.
The method measures the distance from the sound emitting spatial, and factors this with the
noise value it emits. For this example, a threshold of 0.25 is used to define whether the
sound is loud enough for the AI to react.
Search WWH ::




Custom Search