cannot fire second line renderer
Hello. I have two lineRenderers on two separate objects, but only one will fire, I have tried everything I could think of, and then everything the forums suggested. I don't think it is the input settings because other effects on the second object work fine. For reasons I cant comprehend when I fire the second one only the first one fires.
Here is the script for the line renderer;
using UnityEngine; using System.Collections;
public class laserleft : MonoBehaviour {
public float laserStrength;
//line
private LineRenderer lineRenderer;
// source
private Transform shipzero;
// hitpoint
private RaycastHit hitpnt;
// Use this for initialization
void Start () {
shipzero = gameObject.transform;
lineRenderer = gameObject.GetComponent<LineRenderer> ();
// The line is disabled
lineRenderer.enabled = false;
// world space i think is ok
lineRenderer.useWorldSpace = true;
// this will be over written by the options
lineRenderer.SetColors( Color.cyan, Color.blue);
}
// Update is called once per frame
void FixedUpdate () {
// boolean says if it hits. it always will
bool ifithits = Physics.Raycast (shipzero.position, Vector3.right, out hitpnt , 10000f);
if (Input.GetButton ("Laser1")) {
// turns on the line
lineRenderer.enabled = true;
lineRenderer.SetPosition (0, new Vector3( shipzero.position.x, shipzero.position.y, shipzero.position.z));
lineRenderer.SetPosition (1, new Vector3(hitpnt.point.x, shipzero.position.y, shipzero.position.z));
}
else {
lineRenderer.enabled = false;
}
// the physics
if (hitpnt.collider.tag=="ball"){
hitpnt.rigidbody.AddForceAtPosition(hitpnt.point, Vector3.right*laserStrength);
}
// the clause for the other ship
if (hitpnt.collider.tag== "p1"){
hitpnt.rigidbody.AddForceAtPosition( hitpnt.point, Vector3.right*laserStrength);
}
}
}
The script is pretty much the same for both objects, but facing the other way and calling different linerenderers.
Your answer
Follow this Question
Related Questions
First person shooter : Leaning! 2 Answers
Player freaks out when nearing mouse? 0 Answers
How do I get a the movement ofan arm like in truck loader game? 0 Answers
Mouse Look clamping problem 0 Answers
Draw Line from world coordinate to screen coorditate 0 Answers