Our next step is to add some sound effects for the cycles' engines and weapons. Because these are sounds that are being produced by actual objects in our world, we want their volume to be dependent on how far those objects are from the camera. That will give our sound environment a more realistic feel.
Panda3D comes with a utility called Audio3DManager
that makes it easy to set this up. Don't let the name confuse you, though; this isn't a new kind of AudioManager
. It's actually a wrapper that modifies an existing AudioManager
. Using this wrapper, we can tie a sound to an object, define an object that is the "listener", and the volume of the sound will drop as the object it's attached to gets further from the "listener".
We're going to make four new AudioManager
objects that we will use for cycles. They'll be owned by the Race
class because we don't really want to be creating and destroying them each time we make new cycles. Instead, we'll just pass them along from Race...