Network events
SendCustomNetworkEvent runs a public, parameterless method on other players' copies of the script. Use it for
moments (a sound, an effect, a ping) rather than state: state belongs in [Synced] fields, so late joiners get it.
public void PlayChime()
{
chime.Play();
}
public void OnButton()
{
SendCustomNetworkEvent(NetworkEventTarget.All, nameof(PlayChime));
}
| Target | Runs on |
|---|---|
NetworkEventTarget.All | everyone, including you |
NetworkEventTarget.Others | everyone except you |
NetworkEventTarget.Owner | the object's owner only |
NetworkEventTarget.Self | only you (same as SendCustomEvent) |
- You do not need ownership to send a network event.
- Methods whose name starts with
_cannot be called over the network. - Players who join later do not receive past events.