mattrdowney / planetaria

A Unity framework for Euclidean 2-sphere games (e.g. 2D virtual reality games) [quasi-MIT license]
Other
10 stars 2 forks source link

PlanetariaAudioSource #32

Open mattrdowney opened 6 years ago

mattrdowney commented 6 years ago

For e.g. as the player scales in size and approaches the camera.

mattrdowney commented 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)

mattrdowney commented 6 years ago

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.

mattrdowney commented 6 years ago

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

mattrdowney commented 6 years ago

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.

mattrdowney commented 6 years ago

Because sound will play on any Planetarium without extra muting, I'm shelving this for now.

mattrdowney commented 6 years ago

@EmilyClaire was right; this feature isn't mandatory/high priority.

mattrdowney commented 6 years ago

Scrap every idea here and provide sound spatialization along the unit sphere instead.

mattrdowney commented 5 years ago

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.