#NetworkCollider/NetworkTrigger components

2 messages · Page 1 of 1 (latest)

limpid thistle
#

Hello,

I'd like to have some documentation about how to use the new NetworkCollider/NetworkTrigger components.
I've tried to use them on my project, without success.
I have added the NetworkTrigger component to a projectile and used the code as is but doesn't work :

public class MyClass : NetworkBehaviour
{
    private NetworkTrigger2D _networkTrigger2D;
    public override void OnStartNetwork()
    {
            base.OnStartNetwork();
            _networkTrigger2D = GetComponent<NetworkTrigger2D>();
            _networkTrigger2D.OnEnter += OnEnter;
    }
    public void OnEnter(Collider2D other) 
    {
          Debug.Log("Collision");
    }
}

Did I miss something ?

limpid thistle
#

I found why
because of int layerMask = 1 << gameObject.layer; in the source code. the object colliding must be on the same LAYER ⚠️