Question by
WagnerDav · Aug 06, 2020 at 11:40 PM ·
aipathfindingpath
Simple AI, Pathfinding
I'm doing a procedural method to create a map for a tower defense game. For the AI i created a path with waypoint over the road, but when the map is generated, its create clones of the GameObjects.
Also it's created random, its not created from start to exit, the first waypoint is not the first allocated.
Is there a method I can use so that the AI when it arrives at a GameObject goes to the nearest one?
I'm doing:
waypoint = GameObject.Find("Waypoint");
if(Vector3.Distance(transform.position, waypoint.transform.position) <=0.2f)
{
Vector3 dir = (waypoint.transform.position - transform.position).normalized;
transform.Translate(dir * speed * Time.deltaTime, Space.World);
}
But I don't know how I would make it so that he got there and went to another one.
Does anyone have any ideas, what I might look for and study to do this?
Comment