Class NetworkProximityChecker
Component that controls visibility of networked objects for players.
Any object with this component on it will not be visible to players more than a (configurable) distance away.
Inheritance
Inherited Members
Namespace: UnityEngine.Networking
Assembly: com.unity.multiplayer-hlapi.Runtime.dll
Syntax
[AddComponentMenu("Network/NetworkProximityChecker")]
[RequireComponent(typeof(NetworkIdentity))]
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class NetworkProximityChecker : NetworkBehaviour
Fields
checkMethod
Which method to use for checking proximity of players.
Declaration
[Tooltip("Which method to use for checking proximity of players.\n\nPhysics3D uses 3D physics to determine proximity.\n\nPhysics2D uses 2D physics to determine proximity.")]
public NetworkProximityChecker.CheckMethod checkMethod
Field Value
Type | Description |
---|---|
NetworkProximityChecker.CheckMethod |
forceHidden
Flag to force this object to be hidden for players.
If this object is a player object, it will not be hidden for that player.
Declaration
[Tooltip("Enable to force this object to be hidden from players.")]
public bool forceHidden
Field Value
Type | Description |
---|---|
bool |
visRange
The maximim range that objects will be visible at.
Declaration
[Tooltip("The maximum range that objects will be visible at.")]
public int visRange
Field Value
Type | Description |
---|---|
int |
visUpdateInterval
How often (in seconds) that this object should update the set of players that can see it.
Declaration
[Tooltip("How often (in seconds) that this object should update the set of players that can see it.")]
public float visUpdateInterval
Field Value
Type | Description |
---|---|
float |
Methods
OnCheckObserver(NetworkConnection)
Callback used by the visibility system to determine if an observer (player) can see this object.
If this function returns true, the network connection will be added as an observer.
Declaration
public override bool OnCheckObserver(NetworkConnection newObserver)
Parameters
Type | Name | Description |
---|---|---|
NetworkConnection | newObserver |
Returns
Type | Description |
---|---|
bool | True if the player can see this object. |
Overrides
OnRebuildObservers(HashSet<NetworkConnection>, bool)
Callback used by the visibility system to (re)construct the set of observers that can see this object.
Implementations of this callback should add network connections of players that can see this object to the observers set.
Declaration
public override bool OnRebuildObservers(HashSet<NetworkConnection> observers, bool initial)
Parameters
Type | Name | Description |
---|---|---|
HashSet<NetworkConnection> | observers | The new set of observers for this object. |
bool | initial |
Returns
Type | Description |
---|---|
bool | Return true if this function did work. |
Overrides
OnSetLocalVisibility(bool)
Callback used by the visibility system for objects on a host.
Objects on a host (with a local client) cannot be disabled or destroyed when they are not visibile to the local client. So this function is called to allow custom code to hide these objects. A typical implementation will disable renderer components on the object. This is only called on local clients on a host.
Declaration
public override void OnSetLocalVisibility(bool vis)
Parameters
Type | Name | Description |
---|---|---|
bool | vis | New visibility state. |