I have a laser. its goes on forever. But when the laser touches ANYTHING like (wall, player, box, trigger colliders, etc...) it stops there. So it basically doesnt go through colliders.
But I dont want that. I want the laser to ONLY stop if the RaycastHit2D hits a wall. Is there a way to do that? thanks in advance :D
Here's the code:
private LineRenderer lineRenderer;
public Transform LaserHit;
public Transform LaserSpawn;
void Start()
{
lineRenderer = GetComponent<LineRenderer>();
lineRenderer.useWorldSpace = true;
}
void Update()
{
RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.up);
LaserHit.position = hit.point;
lineRenderer.SetPosition(0, transform.position);
lineRenderer.SetPosition(1, LaserHit.position);
}