void GenerateNode() { GameObject go = Instantiate(nodePrefab, nodes[nodes.Count - 1].position + Vector3.down, Quaternion.identity, transform); HoldingDistance script = go.GetComponent <HoldingDistance>(); script.target = nodes[nodes.Count - 1]; nodes.Add(go.transform); smoothnessScript.scripts.Add(script); }
private void Start() { lineRenderer = GetComponent <LineRenderer>(); lineRenderer.positionCount = points + 1; maxPoints = points; smoothnessScript = GetComponent <Smoothness>(); smoothnessScript.scripts = new List <HoldingDistance>(); GameObject go = Instantiate(nodePrefab, player.position + Vector3.down, Quaternion.identity, transform); nodes.Add(go.transform); HoldingDistance script = go.GetComponent <HoldingDistance>(); script.target = player; script.maxDistance = firstNodeDistance; smoothnessScript.scripts.Add(script); Attacking.closestNode = go.transform; for (int i = 0; i < points - 1; i++) { GenerateNode(); } }