Jump to content

Is there any way to play a sound for just one player?


Recommended Posts

I want to play sounds for just 1 player and not everyone in the radius. I've looked into Woodie a lot and see he uses "TheFocalPoint" for his music as well most sounds which are only heard by 1 player like crafting sounds and stuff use it too, but I have no idea how I would even use this.

And even if I could use it would it work for playing any sound whenever I want or can you only make it play specific sounds?

Link to comment
Share on other sites

TheFocalPoint is just an entity that is a children of the player. It has a soundemitter, so you can use it the same way you do it for a player.

When world.lua is initialized:

assert(TheFocalPoint == nil)
TheFocalPoint = SpawnPrefab("focalpoint")

this is called. TheFocalPoint then listens for the event when a player joins and attaches itself to him.

So let's say you had a sound you would like play, you would normally do something like this:

inst.SoundEmitter:PlayingSound("dontstarve/characters/woodie/goose/flap")

If you want only the player to hear it, you just use TheFocalPoint. 

TheFocalPoint.SoundEmitter:PlayingSound("dontstarve/characters/woodie/goose/flap")

As the player is the parent entity, the sound will play where the player is.

So you can use it the same way as you would play sounds for everyone to hear.

Edited by Monti18
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...