Open
Conversation
…ing/exiting AudioZoneColliders while in station.
…dioZonePlayerFollower
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi~
I implemented an optional workaround for the station problem. CapoLock did message u about that already once.
Feel free to contact me via Discord - name is the same. Or message Capo.
Never did a VrChat/Unity package, just scripts I sent the people directly. So if I missed something - or for example all these changed assets are not necessary - let me know.
About the workaround.
As u already know, the Problem is that the PlayerCollider is deactivated when entering a station. Without the collider, OnPlayerTriggerEnter/Exit will never happen.
At the same time we dont have a 100% guaranteed way to detecting a player entering a avatar station.
Even worse, when leaving the Station the "OnPlayerTriggerEnter" will happen, but when entering a Station, OnPlayerTriggerExit wont be called.
Best case szenario:
Nothing happens at all when u are in a station and get carried throgh AudioZoneColliders. U will just no longer be able to hear the one carrying u (and maybe others), since u are stuck in a differen zone.
Worst case szenario:
U were already in a zone and exit it while being in a station. Now the AudioManager will have u forever in that zone and only a rejoin will fix it.
The Workaround adds a follower with a collider and rigidbody.
-This follower is local only. Nothing gets synced
-This follower has an Editor script to configure collider/rigidbody automatically
-This follower will be updated every X seconds (configureable, 0.1 seems fine and saves some performance)
-This follower will detect collision (OnTriggerEnter, OnTriggerExit) only with layer "AudioZone" and will then get the AudioZoneCollider from that to call OnLocalPlayerEnterStationFix or OnLocalPlayerExitStationFix with a slight delay.
AudioZoneCollider got updated with these new functions.
It will do nothing when u entered/exited through normal means (OnPlayerTriggerEnter/Exit).
Otherwise it will send a CustomNetworkEvent to everyone with the local player id. Every client then gets the Player for that id and handles the normal "Player entered/exited AudioZoneCollider"-case.
It will know what to do based on a counter that gets incremented on enter and decremented on exit. This counter is also important when exiting an AudioZoneCollider - see edge case below.
As u know, the AudioManager keeps track of the audio zones by incrementing/decrementing a counter for that AudioZoneId.
This means, if u enter the Zone normally it goes from 0 -> 1, but if u then enter a station and leave the zone, it would be stuck at 1. If u enter again normally it goes from 1 -> 2 and on leaving normally it goes from 2 -> 1, u will be stuck forever.
The Workaround will fix this already, but there is an edge case:
When u enter and leave a station inside of an Audio zone, u always increment the counter more. Lets say u reached a counter of 8. When u then leave normally, it will only decrease the counter by one. In this case the workaround have to decrease the counter for the remaining 7 to reach the 0.
AudioManager was changed to allow decreasing by more than 1.