Triggering an event during sound playback
Torque 3D allows us to set markers on the timeline of a sound that triggers a callback. In this recipe, we will learn how to set markers on a sound source and respond to their callback while a sound is playing.
Getting ready
We will be making TorqueScript changes in a project based on the Torque 3D's FPS Tutorial
template, and try them out using the China Town Day
level. If you haven't already, use the Torque Project Manager (Project Manager.exe
) to create a new project from the FPS Tutorial
template; it can be found under the My Projects
directory. After that, start your favorite script editor, such as Torsion, and let's get going!
How to do it...
In the following steps we will have an explosion trigger based on a sound playing:
Open
scripts/client/game.cs
in a text editor, add the following TorqueScript code to the bottom of the file, and save it:// This function will create an explosion one of the // street lamps as indicated by %lampIndex. function...