Skip to content

Ability to control which sound from a SoundEvent is played. #11355

Description

@Remscar

What can't you do?

I want to be able to synchronize what sound is played from a sound event across all clients.
Right now when I play a sound event it randomly selects a sound to play, but if I trigger the playing of a sound via an RPC, I have no way of ensuring every player is hearing the same sound.

How would you like it to work?

I would like an API exposed like this

SoundEvent se = new SoundEvent(); // assume this is a real sound event
var chosenIndex = Game.Random.Next(0, se.Sounds.Count);
Sound.PlayExact(se, chosenIndex);

Essentially some variation of Sound.Play that allows me to specify an index.

OR, there is a networked version of Sound.Play which plays the same sound across all clients

What have you tried?

Some abomination like this

var handle = Sound.PlayFile(se.Sounds[chosenIndex], 1f, 1f, 0f, 0f);
handle.AirAbsorption = se.AirAbsorption;
handle.Falloff = se.Falloff;
handle.DistanceAttenuation = se.DistanceAttenuation;
// And all the other properties from sound event

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Fields

    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions