Hi I am new to unity and I am trying to create an AI script for an enemy. In this class I have way-points that the enemy will walk to randomly by generating a random number originally I had four way-points but this was very linear. So I added more to make it appear as if the enemy is aimlessly walking around an example can be seen by this - YouTube. I then added in around twenty more way points to complete randomize it but I don’t want to instantiate every one of them so I am wondering is there anyway possible to instatiatie them in a for loop?
Here’s how my code for doing it looks so far:
private var player : GameObject;
private var way0 : GameObject;
private var way1 : GameObject;
private var way2 : GameObject;
private var way3 : GameObject;
function Start()
{
player = GameObject.Find("Player");
way0 = GameObject.Find("way0");
way1 = GameObject.Find("way1");
way2 = GameObject.Find("way2");
way3 = GameObject.Find("way3");
}
Everything else is dealt with in the update function through if statements