Skip to main content

NetworkColliderGroup

A class in Root.Township, Alta.Networking.

A ColliderGroup on a network entity that syncs whether its colliders are on and which other entities it ignores collision with. The server sets them; clients follow.

Constructors​

MemberWhat it is
NetworkColliderGroup()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

8 private and internal fields
MemberWhat it is
private NetworkEntity entityBacking field for Entity.
private bool isDisablingOnStartIf set, the server turns the colliders off when the entity is spawned.
private bool isEnabledWhether the colliders are on, as synced.
private bool isOnDelayTrue while the on-connect delay is running.
private AltaCoroutine onConnectDelayThe running on-connect delay coroutine.
private float onConnectUpdateDelaySeconds a newly connected client waits before applying the enabled state (default 0.5).
private MethodSyncStruct<bool> syncEnabledMethod sync for the enabled state.
private MethodSyncStruct<NetworkColliderGroup.CollisionIgnoreArguments> syncIgnoreMethod sync for ignored collisions.

Properties​

MemberWhat it is
NetworkEntity Entity { get; }The network entity this group is on.

Methods​

MemberWhat it is
void Initialize()Reads whether any collider starts enabled and creates the two method syncs.
void InitializeAsServer(SpawnData spawnData)Server: turns the colliders off if isDisablingOnStart is set.
void OnConnected(Player player)Server: sends the enabled state to a newly connected player.
void OnDisconnected(Player player)Does nothing.
override void SetActive(bool isEnabled)Turns the colliders on or off; on the server also sends the change to clients.
protected override void IgnoreCollision(Collider thisCollider, Collider otherCollider, bool isIgnoring)Ignores collision between two colliders; on the server also sends it to clients by the other collider's entity.
4 private and internal methods
MemberWhat it is
private void NetworkIgnoreCollision(IPlayer player, Stream stream, NetworkColliderGroup.CollisionIgnoreArguments args)Client: ignores collision with all colliders of the other entity, waiting for it to spawn if needed.
private IEnumerator OnConnectDelay() (iterator)Coroutine that applies the enabled state after onConnectUpdateDelay seconds.
private void OnDestroy()Stops the on-connect delay coroutine.
private void Sync(IPlayer player, Stream stream, bool isOnConnect)Sends or receives the enabled state; on connect, clients apply it after a delay.