Resetting network objects when out of bounds
Last updated
Last updated
You can configure network objects to reset if they leave a defined region. For example, you could configure tennis balls to return to a rack if they move outside the bounds of a tennis court.
You use a game object to define the boundary within which specified network objects must remain. Specifically, it is the bounds of the object's collider that defines the permissible region. We recommend that you use a Box Collider component so that you see an accurate representation of the boundary in the Unity editor.
Set the boundary game object's Layer to 20: NoCollision
. This will allow the user to walk through the boundary.
On another game object, add a Network Object Respawn Manager
script component, and then add references to both boundary game object and the network objects that you want to restrict.
Ensure that each network object can achieve a stable position within the boundary. When a game object moves outside of the permissible region, it resets to the first stable position and rotation that it achieved after the scene loaded. If a network object falls and rolls when it loads, its first stable position may be outside the boundary. This would effectively make it ungrabbable.
The following diagram shows an example of how to arrange the components for a single network object in Unity, and the required references.