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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Help making a raycast hit another object through a wall

Discussion in 'Scripting' started by the_Bad_Brad, Aug 6, 2016.

  1. the_Bad_Brad

    the_Bad_Brad

    Joined:
    Nov 2, 2014
    Posts:
    278
    Hello guys. I will be working on the script for my armor piercing sniper rifles that can hit targets behind cover. I have no idea how to simulate that using raycast. I cannot just ignore the wall collider as it needs it to create a wall hit effect and a big hole decal in the wall, just for realism's sake. The script instantiates particle systems when raycast hits a collider
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,146
    I haven't tried this and I'm sure someone already has a cool script that can do this and might come to your rescue. But I wonder if you couldn't just cast a raycast from the wall to further on? Or could you use two raycast where one hits the wall and the other ignores it? Again, not tried, just a thought.
     
  3. GNGification

    GNGification

    Joined:
    Oct 24, 2013
    Posts:
    59
    Use layers and add whatever objects you want to raycast and while raycasting use that layer.

    This will simply ignore everything else.

    Writing on phone, cant give an example or even verify that it works, but there should be enough examples for this
     
  4. the_Bad_Brad

    the_Bad_Brad

    Joined:
    Nov 2, 2014
    Posts:
    278
    Good idea. I will see if it works.
     
  5. novashot

    novashot

    Joined:
    Dec 12, 2009
    Posts:
    373
    eses likes this.