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.
- Listed in Networking and servers
- Inherits or implements
ColliderGroup,INetworkEntityBehaviour - Nested types
CollisionIgnoreArguments
Constructors
| Member | What it is |
|---|---|
NetworkColliderGroup() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private NetworkEntity entity | Backing field for Entity. |
private bool isDisablingOnStart | If set, the server turns the colliders off when the entity is spawned. |
private bool isEnabled | Whether the colliders are on, as synced. |
private bool isOnDelay | True while the on-connect delay is running. |
private AltaCoroutine onConnectDelay | The running on-connect delay coroutine. |
private float onConnectUpdateDelay | Seconds a newly connected client waits before applying the enabled state (default 0.5). |
private MethodSyncStruct<bool> syncEnabled | Method sync for the enabled state. |
private MethodSyncStruct<NetworkColliderGroup.CollisionIgnoreArguments> syncIgnore | Method sync for ignored collisions. |
Properties
| Member | What it is |
|---|---|
NetworkEntity Entity { get; } | The network entity this group is on. |
Methods
| Member | What 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
| Member | What 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. |