Open mattrdowney opened 6 years ago
Because speed of sound seems to be for the Doppler Effect and/or not changeable at runtime:
Instead play sound effects at a point with a delay (using Coroutines).
Something like PlanetariaAudio.one_shot(AudioClip sound_effect, Vector3 position, float time_delay) Consider: playing stereo music tracks from Vector3.down (base) and Vector3.up (rest)
Even better: PlanetariaAudio.one_shot(AudioClip sound_effect, Vector3 position)
Which calculates the distance from the camera center to "position" and multiples it by the planetarium radius to find the time delay.
Use hook for camera position change (zoom) to play all clips at a different "time":
https://answers.unity.com/questions/963843/audiosource-play-certain-time-range-1.html
A sound can be removed from consideration after time [2*(distance)/(speed_of_sound) + clip_length], the 2 being for the diameter (not radius) of the planetarium, and distance being the radius of the Planetarium in which the sound is playing.
During camera movement (zoom), pitch changes to sounds could be done (maybe that's overkill). In theory, there's a way to use only pitch to keep the sound working, but the integration wouldn't be super fun.
Because sound will play on any Planetarium without extra muting, I'm shelving this for now.
@EmilyClaire was right; this feature isn't mandatory/high priority.
Scrap every idea here and provide sound spatialization along the unit sphere instead.
As mentioned in #129 there are implementation issues (although the underlying concept is really easy).
PlanetariaOverlay games get really interesting, though, because PlanetariaAudioSources need to be repositioned every frame. Plus, points that are far away should probably map to behind the player at a distance greater than 1.
For e.g. as the player scales in size and approaches the camera.