VRChat is a primary target for HoloScript environments. The v3.4 compiler target emits raw UdonSharp (U#) C# code, providing direct access to the VRChat SDK 3.x API. This guide covers how to optimize your scripts for the Udon VM and handle networked synchronization.
HoloScript traits are mapped to specialized UdonSharp behaviors and VRC SDK components.
| HoloScript Trait | VRC Component / U# Behavior |
|---|---|
@grabbable |
VRC_Pickup component + OnPickup / OnDrop |
@throwable |
Rigidbody + velocity calculation on OnDrop |
@networked |
[UdonSynced] variables with RequestSerialization() |
@portal |
VRC_PortalMarker with destination mapping |
@spatial_audio |
VRC_SpatialAudioSource |
HoloScript's @networked attribute is highly efficient in VRChat, utilizing Udon's serialization system.
Variables marked with @networked are compiled to [UdonSynced] members.
// HoloScript
object ScoreDisplay @networked {
var score: number = 0
}
// Resulting UdonSharp (simplified)
[UdonSynced] private float score;
By default, HoloScript uses Manual Synchronization for better performance. It calls RequestSerialization() only when a variable changes. To force continuous sync for high-frequency updates (e.g., real-time movement):
object MovingPlatform @networked(sync: "continuous") {
// ...
}
The Udon VM has overhead for every behavior with an Update() loop. HoloScript optimizes this by:
- Consolidating Updates: Merging multiple script updates into a single
HoloManagerbehavior. - Event-Driven Interactions: Preferring
OnVRCPickupandOnPlayerTriggerover polling inUpdate.
Udon has strict memory limits. Avoid creating many small objects dynamically. Instead, use HoloScript's composition blocks to define your scene statically at load time.
- Owner-Only Logic: Crucial interactions are protected by checking
Networking.IsOwner(gameObject). - Validation: HoloScript's
ConstitutionalValidator(if enabled) runs locally on each client to prevent malicious script state from being processed.
- VRC_ObjectSync: For purely physical objects, HoloScript automatically adds
VRC_ObjectSyncto handle physics reproduction across the network. - Layers: Map your geometry to VRChat-specific layers (e.g.,
Walkable,MirrorReflection) for correct visual behavior.