Skip to main content

Custom network RPC

Use TSMP RPC when you need an event to travel through the texture stream. It is useful for delayed interactions, toggles, triggers, and one-shot state transitions.

TSMP RPC does not inject method calls automatically. Call SendTransRPC(methodName, target) from your TSMPNetworkBehaviour.

Minimal RPC component

using K13A.TSMP.Udon;
using UnityEngine;

public class BellSync : TSMPNetworkBehaviour
{
public AudioSource bell;

public override void Interact()
{
SendTransRPC(nameof(Ring), RPCTarget.All);
}

public void Ring()
{
if (bell != null)
{
bell.Play();
}
}
}

SendTransRPC()

public void SendTransRPC(string methodName, RPCTarget target)
ParameterMeaning
methodNamePublic method name to execute on the target behaviour. Use nameof(Method) when possible.
targetLocal, Remote, or All.

RPCTarget

TargetSender behaviourReceiver behaviour
LocalExecutes method immediately.Nothing is queued.
RemoteDoes not execute locally.Queues method for decoded receivers.
AllExecutes immediately.Also queues method for decoded receivers.

If sender and receiver are looped back through OBS or another capture path, All can run once immediately and again after the capture delay.

Reliability and repeat frames

RPCs are visible for transRpcRepeatFrames on the encoder. Increase this when:

  • The capture path drops frames.
  • OBS or Spout produces irregular frame pacing.
  • Interactions are being missed.

Do not use very high repeat counts for rapidly repeated events. A receiver may see the same event longer than expected.

Method restrictions

  • The method must exist on the receiving TSMPNetworkBehaviour.
  • Keep RPC methods public and argument-free for the Udon-safe path.
  • Put data in [TransSync] fields when the event needs parameters.
  • Keep side effects idempotent when repeated frames are possible.

Debug checklist

SymptomCheck
Local action works but delayed action does notEncoder queuedRpcCount, rpcMessageCount, and decoder lastRpcCallCount.
Event is missedIncrease transRpcRepeatFrames and verify frame loss in the debug canvas.
Wrong object receives eventRun Apply Setup and confirm networkId values are unique.