Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma strict
- public var wayPoint01: GameObject;
- private var enemiesAlive: int = 0;
- private var lerpSpeed: float = 0;
- //declaring the array i want the children to be listed in
- var waypoints = new Array ();
- //created a reference to the parent GO i want to take the children from.
- public var wayPointsContainer : Transform;
- function Start () {
- // find and store all waypoints in order
- var n = 1;
- var foundWaypoint = true;
- while (foundWaypoint)
- {
- var newWaypoint = wayPointsContainer.Find("waypoint"+(n.ToString("00")));
- if (newWaypoint != null)
- {
- waypoints.Push(newWaypoint);
- Debug.Log("found waypoint "+newWaypoint.name);
- } else {
- Debug.Log("finished, found "+waypoints.length+" waypoints");
- foundWaypoint = false;
- }
- }
- }
- function Update () {
- var listOfEnemies : GameObject[] = getEnemiesAlive();
- if (listOfEnemies.length == 0)
- {
- //Debug.Log("No Enemies Left");
- lerpSpeed += Time.deltaTime * 0.05;
- transform.position = Vector3.Lerp(transform.position, wayPoint01.transform.position, lerpSpeed);
- }
- else
- {
- //Debug.Log("Enemies Left");
- }
- }
- function getEnemiesAlive()
- {
- return GameObject.FindGameObjectsWithTag ("Enemy");
- }
Advertisement
Add Comment
Please, Sign In to add comment