So i created a LineRenderer to be used a a Laser Gun, it worked fine when I wanted it to shoot from the Gun Position forward but Now that I’m trying to make it go towards the Mouse it mainly just shoots upwards or in a random location. Here is my code so far.
if(Input.GetMouseButtonDown(0)){
var start = transform.position;
laser.SetPosition(0,start);
var location = Input.mousePosition;
var finish = start + location * 10;
var ray : RaycastHit;
if(Input.GetButton("Fire1") && Physics.Raycast (location, start, ray))
finish = ray.point;
laser.SetPosition(1,finish);
Any help is much appreciated.