Nitrox icon indicating copy to clipboard operation
Nitrox copied to clipboard

Footsteps sounds not synced

Open tornac1234 opened this issue 1 year ago • 0 comments

Sound emission is in FootstepSounds.OnStep, a manual EventInstance start depending on hardcoded Player.main states.

It is estimated that there are 2.5 steps/second

Envisaged solution for minimal performance and network overload: create a packet (playerfootstep) containing:

  • ushort playerID
  • byte assetIndex

(packet should be 3 bytes) server processor needs to only forward the packet to other players which can hear the sound (take inspiration from FMODAssetProcessor.cs, check for same sub and distance between players < some hardcoded value, maybe 20f) (thanks @Jannify)

client processors need to find the player associated with playerID, and do the playing steps sound part in FootstepSounds.Onstep (from EventInstance @event = ...) using data that they can compute for each player: fmodasset can be deduced by assetIndex (can make a switch with hardcoded cases 1, 2 and 3 corresponding to precursor, metal and land), volume needs to be calculated with FMODSystem.CalculateVolume, velocity is to be determined by adding some kind of velocity measurement (every frame, velocity = (position - prevPosition) / Time.deltaTime, prevPosition = position), 3D attributes can be determined easily with the remote player's Body

tornac1234 avatar Aug 13 '24 08:08 tornac1234