Time for action – I spy with my little ear
In real life, sound can be occluded (behind closed doors in another room) or obstructed (in the same room, but behind the couch).
The audioRenderer
of SimpleApplication
, however, does not take the scene's walls into account when rendering audio. This means that when you attach audio nodes to a scene, the sound is audible through obstacles. For loud gunshots or ambient sounds in a forest, this may be acceptable. But often, gameplay requires you to hide a sound: you do not want all players to hear the zombies right away—not before they have entered the abandoned warehouse and it's too late.
The sample code given next introduces you to a simple case of directional audio.
- Make a copy of
PositionalSound.java ...
Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.