C#C
C#4y ago
cccc

Line Renderer Help

I am trying to get this code to work
There is no bullet in the map at the start of the game
when the player shoots, a bullet prefab is spawned
i want a line to render from pos1 ( a set point ) to the spawned bullet and repeat everytime
public class LinePositions : MonoBehaviour
{
    public LineRenderer theline;
    public Transform pos11;
    public GameObject BULLET;

    // Start is called before the first frame update
    void Start()
    {
        BULLET = GameObject.FindGameObjectWithTag("Bullet");
        theline.enabled = false;
        theline.positionCount =  2;
    }

    // Update is called once per frame
    void Update()
    {
        if(BULLET != null)
        {
            theline.SetPosition(0, pos11.position);
            theline.SetPosition(1, BULLET.transform.position);
            theline.enabled = true;
        }

    }
}
Was this page helpful?