Zone-scoped, event-driven networking for VRChat worlds. Put networked objects under an LCGNetworkZone and
their synced variables and network events reach only the players inside it.
You keep writing normal Udon networking ([UdonSynced] + RequestSerialization, SendCustomNetworkEvent,
NetworkCalling.CallingPlayer). At build time the package rewrites each compiled program so those calls go
through LCG. It works the same for UdonSharp, Udon Graph and Udon Assembly, and needs no compiler.
LCGUdonSharp is optional.
LICENSE.md)Full documentation: docs.logiccuteguy.com.
Add the LogicCuteGuy VPM listing (https://vpm.logiccuteguy.com/index.json) to
VCC/ALCOM and add LCG Network System, or in Package Manager use Add package from git URL:
https://github.com/LogicCuteGuy/LCGNetwork.git#0.1.0. Use one method per project.
LCGNetworkZone component.Objects outside every zone are routed too, with the whole instance as their zone.
using UdonSharp;
using VRC.SDKBase;
[UdonBehaviourSyncMode(BehaviourSyncMode.Manual)]
public class ZoneCounter : UdonSharpBehaviour
{
[UdonSynced] private int count;
public override void Interact()
{
Networking.SetOwner(Networking.LocalPlayer, gameObject);
count++;
RequestSerialization(); // sent only to players in this zone
}
public override void OnDeserialization() { /* update visuals */ }
}
| You write | With LCG |
|---|---|
[UdonSynced] + RequestSerialization() (Manual sync) | The owner sends each synced variable in an LCG packet; receivers get one OnDeserialization. OnPreSerialization/OnPostSerialization still run. |
SendCustomNetworkEvent(target, "Event", args...) | Sent as an LCG packet to zone members only. |
NetworkCalling.CallingPlayer | The verified sender of the packet being handled. |
Native rules still apply: synced variables accept writes only from the object owner, events need variable
sync other than None, and events starting with _ stay local unless marked [NetworkCallable].
Left on native networking:
VRCUrl. A warning names the variable. LCG carries bool,
integer types, float, double, char, string, Vector2/3/4, Quaternion, Color, Color32 and
arrays of these.| Component | Role |
|---|---|
LCGNetworkZone | You add this. A trigger volume whose members share packets and ownership. Exit Mode sets what a player sees after leaving: Freeze, RestoreDefaults or DisableChildren. |
LCGZoneOwnershipGuard | Generated. Refuses ownership requests from players outside the zone. |
LCGManualObjectSync | Generated. Replaces VRC Object Sync inside zones. It syncs on demand and while the object is held. |
LCGRuntime, LCGRuntimePlayer | Generated. The packet router and each player’s mailbox (a PlayerObject). |
Generated components exist only in the build or Play Mode copy of the scene. Your scene is not modified.
With the SDK’s own UdonSharp you can also mark fields and methods with [LCGPacket] and send to one player:
public LCGRuntime lcg; // filled at build; leave empty
[HideInInspector] public VRCPlayerApi __lcgPacketSender; // sender while a handler runs
[LCGPacket(Authority = LCGPacketAuthority.ObjectOwner, Callback = nameof(OnLightChanged))]
private bool lightOn; // set it, then RequestSerialization()
[LCGPacket(Authority = LCGPacketAuthority.Any), NetworkCallable]
public void ReceivePing(string message) { }
void Ping(VRCPlayerApi player) =>
lcg.SendToPlayer((UdonBehaviour)(Component)this, player, nameof(ReceivePing), new object[] { "hi" });
Authority is Any, ObjectOwner or Master. Methods with parameters also need [NetworkCallable], which
supplies the parameter names. LCGUdonSharp builds on the SDK’s UdonSharp, so all of this works the same there.
Import LCG Network Examples from Package Manager:
StockUdonSharp/LCGStockLamp.cs: a zone lamp using [LCGPacket], SendCustomNetworkEvent and SendToPlayer.UdonAssembly/LCGAsmLamp.uasm: the same lamp in plain Udon Assembly, with no LCG-specific code.For Udon Graph, any normal networking graph works, for example the SDK’s ButtonSyncAnyone.
Preview (0.1.0). Verified in Play Mode with ClientSim Net and two simulated players. Not yet verified in a real multi-client VRChat build, so test with Build & Test before publishing a world. The wire protocol may change between versions.
com.logiccuteguy.lcgnetwork
未設定
0.1.0
2022.3 以降
なし
なし
LogicCuteGuy