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

Make Bullet prefab ignore 1 collider

Discussion in 'Scripting' started by linhmut1, May 11, 2021.

  1. linhmut1

    linhmut1

    Joined:
    May 6, 2021
    Posts:
    11
    Hello guys ,i am new to Unity , i was trying to make my Enemy AI with a trigger Collider to follow the player when the player in the trigger zone , but the problem is my bullets now effected by this trigger zone also , so how do i ignore this trigger zone so my bullet can hit the enemy
    I tried to set the collider enable = false when ever the player press "LeftMouse" but it was not good enough,
    u guys have any suggestions ? thanks.
     

    Attached Files:

    • hep.png
      hep.png
      File size:
      13.9 KB
      Views:
      241
  2. RonHClemons

    RonHClemons

    Joined:
    Mar 17, 2021
    Posts:
    5
    good question
     
  3. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,904
    You need to put your bullet and your trigger zone in different layers. See the right side of the screenshot below where you can set the layer.
    Make sure that in the PlayerSettings your two layers unchecked, so they don't affect each other. (see the settings portion of the screen shot). Be careful, you will need to set up in a way when the bullet still can collide with the other colliders.
    Click for full view:
    screenshot1.png
     
    linhmut1 likes this.
  4. linhmut1

    linhmut1

    Joined:
    May 6, 2021
    Posts:
    11
    Thank you so much , follow your instruction i created another gameobject and put my enemy object in it so i can put the trigger collider to the gameobject and have the layer different with the children (Enemy) object and it worked
     
    Lurking-Ninja likes this.