Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Collision ignoring matrix

Discussion in 'Physics' started by nelson182, Nov 21, 2023.

  1. nelson182

    nelson182

    Joined:
    Jan 7, 2019
    Posts:
    2
    Hello,

    Im having trouble with setting up a sticky grenade on an FPS im working on. I'm using rigidbody to handle physics. The grenade is on the Bullet/Grenade layer (which should only interact with the Default and Hitbox layer, pls ignore AI layers for the sake of this post).

    However, when thrown to other players, the grenade detects a collision with the root player object (which is on layer Player). Proof of this on the log png which is the result of the following code:

    Code (CSharp):
    1. Debug.Log($"Collided with: {other.gameObject.name} {other.gameObject.layer}");
    I tried changing the layer of the player root object to Hide (which interacts with nothing at all). It still detects the same collision!!!

    Visually I can tell the grenade is colliding with the capsule and since it and the player root object share the same layer somehow the collision detected is the root and not the capsule. I even tried making it ignore collision, it did nothing.

    Code (CSharp):
    1. foreach (Player p in GameManager.instance.pid_player_Dict.Values) Physics.IgnoreCollision(grenade.GetComponent<Collider>(), p.playerCapsule.GetComponent<Collider>());

    This is really confusing, can anyone explain this to me?

    Thank you for your help.

    - Nelson
     

    Attached Files:

  2. nelson182

    nelson182

    Joined:
    Jan 7, 2019
    Posts:
    2
    Disappointed to see no one has an idea why this is. Maybe I didn't explain the issue clearly enough though. I'll simply go with "that's just how Unity works" for now.

    Thank you to all who read.