What is wrong with this script? Whenever I run it I get no errors and it runs completely fine, but in game it only shows up as a single line and since it’s only a single line I can’t tell if it’s actually working or not. My only issue with this script is that the lines aren’t showing up correctly.
using UnityEngine;
using System.Collections;
public class Emission : MonoBehaviour {
public Vector3 position;
public static Vector3 staticPosition;
public Vector3 direction;
public static Vector3 staticDirection;
void Start () {
position = transform.position;
staticPosition = position;
direction = transform.TransformDirection (Vector3.forward);
staticDirection = direction;
}
void FixedUpdate () {
LineRenderer lineRenderer = GetComponent <LineRenderer>();
RaycastHit hit;
if (Physics.Raycast (position, direction, out hit)) {
lineRenderer.SetVertexCount (2);
lineRenderer.SetPosition (0, position);
lineRenderer.SetPosition (1, hit.point);
position = hit.point;
direction = Vector3.Reflect (position, hit.normal);
}
else {
position = staticPosition;
direction = staticDirection;
}
}
}
Also, when I use Debug.DrawLine it shows up as a line of the same length except it’s constantly blinking. As said, My only issue with this script is that the lines aren’t showing up correctly.