How to make a laser beam effect with raycast?

Hey everyone, new here but I’m looking to make a raycast laser beam effect similar to something like in portal, where the laser hits an object and makes object reacts in some way (that parts not important). What I really can’t figure out is how to make a physical laser beam effect. I found this tutorial online which provided the code:

#pragma strict

var LaserOrigin: Transform; // Put the laser (line renderer) object here.

var LaserTarget: Transform; //The point light object.
function Update () {

        var ray =  new Ray(LaserOrigin.transform.position, LaserOrigin.transform.forward); //Casts a new ray

        var hit: RaycastHit;


        if(Physics.Raycast(ray, hit, Mathf.Infinity))



                LaserTarget.transform.position = hit.point; //Positions the light at the same point the laser hits something.



I created the line renderer with a perlin noise material, and put it as the public variable, but when I use this script, the light beam doesn’t show up, or when I turn the Use World Space off, it only goes like 1 unit out. What is the best way to create a laser beam effect? If possible, I was hoping to use a particle system as well. Thank you for your help in advance.

Look at this tutorial: Survival Shooter Tutorial - 7 of 10 : Harming Enemies - Unity Official Tutorials (new) - YouTube

I think that it’s what you need :slight_smile: