- Unity 2018 Cookbook(Third Edition)
- Matt Smith
- 84字
- 2025-02-23 18:56:39
Delaying before playing a sound
Sometimes we don't want to play a sound immediately, but after a short delay. For example, we might want to wait a second or two before playing a sound to indicate the slightly delayed onset of a poison drunk or having walked into a spell that weakens the player. For such cases, AudioSource offers the PlayDelayed(...) method. This recipe illustrates a simple approach for such cases where we do not wish to immediately start playing a sound.