Skip to main content

TSMPNetworkBehaviour

Namespace: K13A.TSMP.Udon

Base type for TSMP-synchronized behaviours.

Use this when a component should participate in TSMP message routing. It provides a network ID, receive interpolation policy, lifecycle hooks, and SendTransRPC.

Fields​

FieldTypeUse
networkIdushortRoutes payload messages to this behaviour.
sendModeSendModeComponent-wide override of automatic fields' change filtering. Defaults to Default.
receiveInterpolationReceiveInterpolationModeControls receive behaviour.
continuousInterpolationRatefloatSmoothing rate for continuous receive mode.
transRpcEncoderTSMPEncoderEncoder used by SendTransRPC. Assigned by setup.
lastVariableHashuintLast received variable hash.
lastRpcHashuintLast received RPC hash.
lastRpcNetworkIdushortNetwork ID for the last received RPC.
lastRpcArgumentCountintArgument count for the last received RPC.
lastRpcMethodNamestringMethod name for the last received RPC.

Do not assign transRpcEncoder manually in normal scenes. Let TSMPSetup assign it.

SendMode​

Namespace: K13A.TSMP.Udon. Inspector label: Send Mode.

ValueNumeric valueEffective SendOnChange
Default0Each field's attribute setting.
OnChange1true for every automatic field on this component.
Always2false for every automatic field on this component.
sendMode = SendMode.Always;

Changes are read during encoding, without rebuilding bindings. The existing field snapshots and successful-output times remain intact, so switching modes does not bypass MinSendInterval. Unknown enum values fall back to Default. Existing scenes and prefabs without this field use Default.

This override does not modify attribute metadata, priority, direction, capture logic, RPC behavior or manual Writer calls. OnChange retains the Encoder's periodic refresh. Always remains subject to minimum intervals and payload capacity. See Send Mode for usage examples.

ReceiveInterpolationMode​

ValueMeaning
NoneIgnore received values.
DiscreteApply received values directly.
ContinuousStore targets and interpolate where supported.

Built-in components decide how to use Continuous. Custom components should check receiveInterpolation before applying received data.

Lifecycle methods​

MethodCalled when
TSMPBeforeEncode()Before encoder reads [TransSync] fields.
OnTSMPVariableReceived()After decoder applies a synchronized field.
OnTSMPVariableChanged(uint variableHash)From the base receive handler.
OnTSMPRpcReceived()After decoder dispatches a TSMP RPC.
OnTSMPRpc(uint rpcHash)From the base RPC receive handler.

Typical custom component flow:

public override void TSMPBeforeEncode()
{
packedBytes = BuildPacket();
}

public override void OnTSMPVariableReceived()
{
if (receiveInterpolation == ReceiveInterpolationMode.None)
return;

ApplyPacket(packedBytes);
OnTSMPVariableChanged(lastVariableHash);
}

Utility methods​

MethodUse
IsTSMPActive()Returns enabled and active-in-hierarchy state.
GetReceiveInterpolationStep()Returns a clamped 0..1 interpolation step.
SendTransRPC(string methodName, RPCTarget target)Queue an RPC event through TSMP.

RPCTarget​

ValueBehaviour
LocalExecute locally only.
RemoteQueue for receivers only.
AllExecute locally and queue for receivers.

SendTransRPC hashes the method name and queues it through the assigned encoder. The receiving side dispatches by method name after decode.

Example RPC​

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

public void ToggleObject()
{
target.SetActive(!target.activeSelf);
}