Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Physics.Raycast doesn't work. Constantly ignoring enemies

Discussion in 'Physics' started by divineiwu01, Aug 23, 2019.

  1. divineiwu01

    divineiwu01

    Joined:
    Jun 7, 2019
    Posts:
    28
    I have a small shooter ga!e that I'm currently busy making and in the game I gave the player the upgrade of using a laser, I used a line renderer to make the laser and in the update function I will cast raycasts every fra!e rate and where it collides I set the line renderer's length to the raycast hit's distance, simulating an actual laser but the problem is that the laser has to kill the enemy zombies and the zombies have a death function stored on them, all I need to do is to call it and I do so using an if statement

    If(hit.collider.tag=='Invader') Then it will send a message to call the death function on the zombies But instead my raycast just goes through the zombies and it doesn't trigger any death function I checked and the zombies have collider's and I made sure that their layers aren't been ignored by the raycast but nothing works The raycast still ignores the zombies Please help me Thanks in advance
     
  2. MathewHI

    MathewHI

    Joined:
    Mar 29, 2016
    Posts:
    109
    Does the line renderer stop at the zombie or go straight through?