Resetting network objects with a button

You can add a button to your scene that will reset one or more network objects to predefined coordinates. For example, you can add a reset button to a cornhole game that returns all of the beanbags to their starting points.

For each network object, you create a game object that defines the desired reset transform. To trigger a reset, you call the UpdateAllTransformValuesManualViaReference method of the network object, and pass a reference to the game object that defines the reset transform.

The following diagram shows an example of how to arrange the components for a single network object in Unity, and the required references.

Example use of a button to reset a network object's position

You can use a single button to reset multiple network objects. Ensure that you create a game object to define the reset transform of each game object, and then add a reset call to each network object in the button's OnClick event list.

Example hierarchy of network objects and game objects to define their reset transforms
Calls to reset network objects

Last updated