Hey,
I have an idea for my game but couldnt figure out how im supposed to make it work. When the Player Collide with an object a line should appeare between the Player and the object and when the player moves the line should move too. I tried withe 3 scripts but then the console say:
NullReferenceException: Object reference not set to an instance of an object
LrTesting.Update () (at Assets/LrTesting.cs:13)
```csharp
**using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LineController : MonoBehaviour
{
public LineRenderer lr;
public Transform points;
private void Awake()
{
//if (lt.LineConect == 2)
//{
lr = GetComponent<LineRenderer>();
//}
}
public void SetUpLine(Transform[] points)
{
//if(lt.LineConect == 2){
lr.positionCount = points.Length;
this.points = points;
//}
}
private void Update()
{
//if (lt.LineConect == 2)
//{
for (int i = 0; i < points.Length; i++)
{
lr.SetPosition(i, points[i].position);
}
//}
}
}**
** **
csharp
**using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LineTower : MonoBehaviour
{
public int LineConect = 1;
void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == “Player”)
{
LineConect = 2;
Debug.Log(“Do it”);
}
}
}**
** **
csharp
**using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LrTesting : MonoBehaviour
{
[SerializeField] private Transform points;
[SerializeField] private LineController line;
public LineTower lt;
private void Update()
{
if (lt.LineConect == 2)
{
line.SetUpLine(points);
}
else
{
Debug.Log("Please");
}
}
}**
```