Jump to content

HELPHELPHELP How do i make a custom sound play upon spawn of my player mod?


Recommended Posts

Assuming you want your character to play this sound whenever it appears in the world you can simply put:

inst.SoundEmitter:PlaySound("your_sound")

in your characters fn() after:

if not TheWorld.ismastersim then
	return
end

This way your character will play your sound every time it joins a server or switches from surface to caves and vice versa.

 

If you want to play the sound only when your character is created (so only play the sound once) you would need to listen for the "ms_newplayerspawned" event and play the sound then.

  • Like 1
Link to comment
Share on other sites

On 4/5/2022 at 7:11 AM, -t- said:

Assuming you want your character to play this sound whenever it appears in the world you can simply put:


inst.SoundEmitter:PlaySound("your_sound")

in your characters fn() after:


if not TheWorld.ismastersim then
	return
end

This way your character will play your sound every time it joins a server or switches from surface to caves and vice versa.

 

If you want to play the sound only when your character is created (so only play the sound once) you would need to listen for the "ms_newplayerspawned" event and play the sound then.

Hello i know this is MONTHS later but i'm not sure howto put this in? image.thumb.png.fab6234b46d9780c370f4e8bde4116af.png

Link to comment
Share on other sites

In your characters file you should have a function called 'fn()'.

In this function there should be a piece of code that looks like this:

if not TheWorld.ismastersim then
    return inst
end

Put 'inst.SoundEmitter:PlaySound("your_sound")' after that.

 

From what you sent it seems your trying to play the '.mp3' file directly, which is not possible. You need to create a '.fsb' file using FMOD Designer. You can find it in your Don't Starve Mod Tools. If you don't know how to create sounds I recommend this tutorial:

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...