Allows you to call events/methods over the network with ease and support for sending parameters over the network.
Use the VCC Listing to install the package via the VPM.
- Add the
NetworkManager
component to aGameObject
. It is recommended that this is put into root of the scene. And must be only one in the scene. - On
NetworkManager
set the amount ofNetworkedEventCaller
s you wish to generate and press "Setup NetworkManager". This number should be at least the max occupancy of your instance * 2 + 2. This will generate theNetworkedEventCaller
instances and set them up.
2. Use SendMethodNetworked
to send a method/event over the network. The parameters you send must match 1:1 in type and order to the parameters of the method/event you are calling. Otherwise this will crash the UdonBehaviour.
public override void Interact()
{
SendMethodNetworked(nameof(CoolMethod), SyncTarget.All, Time.time, new DataToken(transform.position), new DataToken(transform.rotation), new DataToken(Networking.LocalPlayer));
}
public override void Interact()
{
otherBehaviour.SendMethodNetworked(nameof(OtherBehaviourClass.CoolMethod), SyncTarget.All, Time.time, new DataToken(transform.position), new DataToken(transform.rotation), new DataToken(Networking.LocalPlayer));
}
[NetworkedMethod]
public void CoolMethod(float time, Vector3 position, Quaternion rotation, VRCPlayerApi player)
{
Debug.Log($"{time} - {position} - {rotation} - {player.displayName}");
}