I’m trying to make a DJ box that amplifies a player’s voice throughout the map making use of this script I wrote:
I have the script attached to a box collider to act as the DJ box:
Now this on it’s own works fine. My problem is that I have the collider gameobject disabled by default, and turn it on with another script. When the collider turns on, it seems to not register the OnPlayerTriggerEnter events anymore.
any ideas on how to fix this??
Disable the collider component only instead of the gameObject itself. The UdonBehaviour need to register properly for it to function, so having it disabled could cause it to not register.
Are you testing this with multiple clients?
I don’t see any networking going on.
@PhaxeNor I tried what you suggested, but it still didn’t seem to work. maybe my udon script is just wrong though:
@unigold I am testing with multiple clients, the idea though is that the collider is only active locally, that way the DJ can have their voice boosted, and random guests who wander into the DJ box aren’t boosted. So I’m not sure networking is needed, unless the API variables for player voice distance aren’t synched for late joiners.
How do you determine if a player that walked into the collider should have their voice boosted?
The collider activation button is passcode locked, so only the dj has the code to turn on the collider locally. So a guest will not have the collider active and therefore will not have their voice boosted.
If the collider is only there for the player that walks into it, then it isn’t there in the other player’s instances of the game to increase the DJ’s voice volume.
the SetVoiceGain, SetVoiceDistanceNear, etc functions do not network at all, they only run locally when called. So I think you’re only increasing the DJ’s voice range for the DJ themself which of course they don’t hear because they don’t hear their own voice in game.
Maybe when a player enters the correct keycode it should sync that players playerID, then on deserilization the other players instances can use the playerID you synced to get the VRCPlayerAPI instance of the player with that ID and then increase their volume with that.