July 2017
Beginner to intermediate
390 pages
10h 53m
English
It is time to actually make the sound audible. We want the sound to play as soon as we add a guitar to our scene.
Well, to be honest, we have already done this. Since we have added an audio source to our prefab and set it to play on awake (and loop as well), it will play the moment you instantiate an object.
You will hear the sound immediately, but let's say for the sake of completeness that we want to control this from a script. Let's assume some other piece of code calls Play Sound, and we want our guitar to respond to that.
Let's change our application a bit so that it does just that.
First, we remove the Play on awake and Loop options in the AudioSource component; we want it to play when we ask it to, ...
Read now
Unlock full access