Im Writting a Script that will generate a list of connect waypoints but the only thing is im stuck with the last peice of code…
this is my code
#pragma strict
@script ExecuteInEditMode()
/************************************************************************************************************/
// Simple Waypoint Script.
// Author: Harley Urquhart
// Version: 1
/************************************************************************************************************/
//Notes
//This Requires that at least one other waypoint is included as a link
//Behaviours can then be made
/************************************************************************************************************/
//Variables
var Links : Transform[];
/************************************************************************************************************/
function Awake(){
//test for errors
if (Links.Length <1){
//display an error and the name of the waypoint
Debug.LogError("Please assign at least one object to the array of waypoints in the editor for: " + gameObject.name);
}
if(gameObject.CompareTag("Untagged")){
// Set the Tag Immediately if the player forgot to tag the Waypoint Prefab
gameObject.tag = "Waypoint";
}
}
function Start () {
//make the object invisible
renderer.enabled = false;
//turn off collisions
collider.enabled = false;
}
function Update(){
// draw a ray to visualise the path between Two way points(minimum)
// create a forloop
//instead of manually adding linked waypoints
//find waypoins that are not obscured by any colliders
//then link them together by adding that waypoint to the links array
// Find all game objects with tag Waypoint
var Waypoints : GameObject[];//array of all tagged Gameobjects
Waypoints = GameObject.FindGameObjectsWithTag("Waypoint");
var position = transform.position; //
//find waypoints that are not blocked by a collider.
for (var waypoint : GameObject in Waypoints) {
//cast out a ray
var hit : RaycastHit;
if (Physics.Raycast (position, waypoint.transform.position, hit)) {
}
}
for (var x = 0; x < Links.Length;x++){
//iterate through all the coonected waypoints and cast rays out
Debug.DrawLine(transform.position, Links[x].position,Color.red);
}
}
function OnDrawGizmos () {
Gizmos.DrawIcon (transform.position, "Light Gizmo.tiff", true);
}
i just need help at line 53 to inset the correct code here