Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to shoot rigidbodies through mesh collider with no collision (one way)?

Discussion in 'Scripting' started by Zeppi123, May 30, 2022.

  1. Zeppi123

    Zeppi123

    Joined:
    Mar 28, 2022
    Posts:
    27
    Hello,
    I have a tower which is shooting projectiles. The tower has a mesh collider, so my player can't run through it. The problem is, that my projectiles (rigidbodies) are shooting weird, because of the mesh collider, but I need a collider because of my player.
    Without the collider, the projectiles are flying normal.

    Maybe someone has an idea.
    Thank you.
     
  2. Nitsan448

    Nitsan448

    Joined:
    Aug 22, 2019
    Posts:
    14
    I think what you are looking for is layer-based collision detection
    https://docs.unity3d.com/Manual/LayerBasedCollision.html

    You will want your projectiles and towers to be on a different layer (you can do this in the inspector).
    Then in Project settings -> Physics, you can disable the collisions between them in the Layer Collision Matrix.
     
    Zeppi123 and Kurt-Dekker like this.
  3. Zeppi123

    Zeppi123

    Joined:
    Mar 28, 2022
    Posts:
    27
    Thank you, I will try it.
     
    Nitsan448 likes this.