Hello. I'm trying draw a line between several Gizmos in the map (waypoints), but I don't know how to do this. My current code is: Code (csharp): using UnityEngine; using System.Collections; public class WayPoint : MonoBehaviour { //Array //ArrayList Nwaypoints; //Variables private bool ActiveBucle = true; private int WaypointID; //Draw gizmo waypoint void OnDrawGizmos() { Gizmos.DrawIcon(this.transform.position, "WayPoint.tif"); } //Draw line between waypoints void OnDrawGizmosSelected() { DrawThePath(); } GameObject DrawThePath() { GameObject[] FindWaypoints = GameObject.FindGameObjectsWithTag("Waypoint"); foreach (GameObject CurrentID in FindWaypoints) { if (Physics.Linecast(CurrentID.transform.position, CurrentID.transform.position)) { Gizmos.color = Color.red; Gizmos.DrawLine(CurrentID.transform.position, CurrentID.transform.position); } else { Gizmos.color = Color.white; Gizmos.DrawLine(CurrentID.transform.position, CurrentID.transform.position); } } return null; } } I'm lost with this, does anyone help me?
You try to draw from current to current point: CurrentID.transform.position, CurrentID.transform.position. !PREV_ID!.transform.position, CurrentID.transform.position. And linecast too. Good luck =)
That user was last seen over 9 years ago... Please check the date of the last post next time you post something.