Udon# SendCustomNetworkEvent

I am trying to send a custom network event only when my trigger hits a specific collider, and I would think this would work, but it doesn’t. The “SendCustomNetworkEvent” doesn’t seem to work in this, even without the if statement, and I have no idea why.

Your script looks operational. Check if the event is even being executed by logging it to the console with Debug.Log("Some text"). If it is not logging to the console, check that you have set up the colliders correctly. Refer to this section in the Unity docs: Unity - Scripting API: Collider.OnTriggerEnter(Collider)

Note: Both GameObjects must contain a Collider component. One must have Collider.isTrigger enabled, and contain a Rigidbody. If both GameObjects have Collider.isTrigger enabled, no collision happens. The same applies when both GameObjects do not have a Rigidbody component.

There is no log and my colliders are all set up properly. If I replace the “SendCustomNetworkEvent” with just changing the text it works, but I need it to be a global change. I think I just need to solve a different issue in my world, the dice clone isn’t global either so when one player rolls it, the other players can’t see that. I think fixing that will make the text change for all players.

I have figured out that cloned objects don’t keep object sync so that is why they weren’t working. I will have to figure out a new way to get them working, maybe object pools?

You figured it out, yeah! :smile:

If you’re instantiating objects, they won’t synchronize over the network. You’ll probably want to use an object pool. You can either make your own, or try VRChat’s VRC Object Pool. This has other advantages, too. In-game it’s usually faster to re-use objects from an object pool instead of creating and destroying objects.