Network state animation start/stop
Last updated
Last updated
You can use a network state to synchronize animations. The example described on this page expands on the example provided in Network state toggle object to synchronize whether an animation plays. With minor adjustments you could also switch between different animations.
To synchronize an object's animation state, you can use the NetworkStateTrigger_ToggleObjects
script to toggle a target object between enabled and disabled states. You can then use an OnEnableDoEvent
script on the target object to respond to the enable and disable events.
You can use the OnEnableDoEvent
script to call any methods on objects in the scene. In this example, the OnEnableDoEvent
script calls the StartPlayback
and StopPlayback
methods of an Animator component.
The following diagram shows an example of how to arrange the components in Unity, and the required references.
To switch between animations that are defined for an object, call the Play
method of the Animator component, and include either an integer or string parameter that identifies the animation that you want to play. For more information, see Network state change animation.