Hello,
I am trying to us Line-Renderer to be able to see my Space-Ship shoot lasers, but when i do render the line it goes from the laser origin cube to the ship instead of the the actual target?
Raycast Code:
var laserOriginOne : GameObject;
var hitOne : RaycastHit;
function Update () {
if(Input.GetButton("Fire Laser")){
if(Physics.Raycast(laserOriginOne.transform.position, Vector3.forward)){
laserOriginOne.GetComponent(ShipFire).FireLasers(hitOne);
Debug.Log(hitOne.transform);
}
}
}
‘FireLasers()’ Code:
var lineOne : LineRenderer;
function Start() {
lineOne = GetComponent(LineRenderer);
lineOne.enabled = false;
lineOne.SetVertexCount(2);
lineOne.SetWidth(0.1f, 0.25f);
}
function FireLasers(hitOne : RaycastHit){
lineOne.enabled = true;
lineOne.SetPosition(0, transform.position);
lineOne.SetPosition(1, hitOne.point);
}
Like i said i don’t know why the laser goes from the ‘laserOriginOne’ to my ‘ship’?
I have tried a few thing such as moving my ship away from the laserOrigin blocks.
Thanks for any help!