A Basic guide on the different ways to play a sound effect in-game
This is a very basic tutorial so you don't need much knowledge to do it successfully.
Wolven kit
Any text editor capable of opening a big JSON file without crashing
That's about it.
This tutorial presumes that you already have a mod project in WolvenKit and will not walk you through how to create one.
If you don't have redscripts in your project, you will need to add the following structure to your resources folder inside your mod folder:
There are 3 documented ways to play sounds using scripting. Two are linked to the event system and the third one is linked to a helper function:
If you try to run the script now it will most likely fail because you don't have the player object used to queue or play the event.
So how to get the player?
It's actually quite easy, once a save has been loaded, you can simply use:
You are not even obligated to get the player. You can use any GameObject
capable of handling events in the event way and you can use any GameObject
at all using the helper function. If it isn't valid, the GameObject
method will use the game engine to play the sound. (It will not be spatialized this way)
If you did everything correctly, your sound should be played in the part of the script where you used it.
And now, you will probably want to play other sounds. Sounds played by the game are referenced using a redIdentifier.
To find many of these identifiers for sounds, you will need to use WolvenKit and navigate to:
You can then import it into your project, turn it into JSON and explore the JSON file to find all the tags, for example:
Use any of these IDs and experiment!
There is a lot of them so use string search to find them more quickly. You can also search for them in the events
array for an easier search with tags.