Important! Please read the announcement at http://myst.dustbird.net/uru-account.htm
Also! Please read the retirement announcement at http://myst.dustbird.net/uru-retirement.htm

Enter and Exit Triggered Sounds

From UamWiki

This tutorial addresses the need to have a sound play when the avatar enters an area, and then play either the same or different sound when leaving the area (Think Myst V when entering or leaving the bubbles).

The tutorial assumes that you know how to put in basic sounds and 3D Sounds. It also assumes you know how to put in a logic region.


Setting Up.....

This is really not that hard. The hard part is, as with many things with Age building, if you want to do something that you need ALCscripting for, you sometimes have to put it together yourself (or hope someone like me puts it together for you).

Let's say you have the need to put in something so that when the Avatar enters a certain area, a sound plays. Maybe it's a Bahro screaming, maybe the sound of a rock falling. Having the sound play just once when the avatar enters the region is easy by simply using a Sound Region to trigger the sound. I cover that in another tutorial.

But lets say you need the sound to play when you both leave AND exit the region. Or better yet, a sound plays when you enter the region, and a different sound plays when you leave the region. In this case a simple sound region won't work. But there is a way to do it by using a logic region.


Step One: Sensor Region

First you need to put in a logic region around the area that the Avatar will be entering and exiting. The region can be any shape, just remember to keep it simple: too many faces on a region can break them.

Once you have a region put in, scaled and rotated, make sure you hit Cntl-A to Ob the scaling and rotation data.

Next, make the region an Actor, and turn Bounds on (if Convex Hull doesn't work, try Triangle Mesh).

Give the region a name that makes sense.


Step Two: Sound Emitters

Now you need to put in your sound emitters.

In this example, I use 2 as I have 2 different sounds I want played, one upon entering and one upon exiting.

Give the emitters names that make sense.


Step Three: ALCscripting

Now for the scripting:

The following script is for the logic region:

<YourRegionName>:
    logic:
        modifiers:
          - name: Enter_Snd_Rgn
            flags:
              - multitrigger
            activators:
              - type: objectinvolume
                triggers:
                  - enter
            conditions:
              - type: volumesensor
                satisfied: true
                direction: enter
            actions:
              - type: responder
                ref: :SndPlay
          - name: Exit_Snd_Rgn
            flags:
              - multitrigger
            activators:
              - type: objectinvolume
                triggers:
                  - exit
            conditions:
              - type: volumesensor
                satisfied: true
                direction: exit
            actions:
              - type: responder
                ref: :SndPlay
        actions:
          - type: responder
            name: SndPlay
            responder:
                states:
                 - cmds:
                    - type: soundmsg
                      params:
                          receivers:
                           - 0011:<Your Enter Sound Emitter's Name>
                          cmds:
                           - play
                           - setvolume
                          volume: 0.5
                      waiton: -1
                   nextstate: 1
                   waittocmd: 0
                 - cmds:
                    - type: soundmsg
                      params:
                           receivers:
                            - 0011:<Your Exit Sound Emitter's Name>
                           cmds:
                            - play
                            - setvolume
                           volume: 0.5
                      waiton: -1
                   nextstate: 0
                   waittocmd: 0
                curstate: 0       
                flags:
                  - detecttrigger

Then you put in the scripting for your 2 sound emitters.

That's it! Your done!


Return To: Andy's Blender Tutorials