I have my enemy that follows the player around when he gets into a certain range. When there is no target nearby/if he loses/kills the target, he should walk aimlessly around. When he is walking around, he should pick a random nearby waypoint, go to it, then pick another, go to it, and repeat. How would I do this? I have thought to have a bunch of waypoints that each have a list of other waypoints they connect to, but there must be a quicker way.
All help is appreciated,
You can consider using Random to generate a way-point from your current point.
Assuming your point would be x,z and y is the altitude you could great a Vector3(x+Random.value20f-10f,-WAYABOVETERRAINT,z+Random.value20f-10f) way above the terrain and ray-cast down to get the y at the coordinate. (One issue will be if there is a suitable path to that point.
Generally we try keep tack of our mobs home point if the chasing the player they will return to there “home” location before roaming. Then roaming random points would only be generated within a radius of there home point. (you can do this easily with some trig, generate a random angle and radius from home then do the above ray-cast to find the complete vector.) A more sophisticated roam would only adjust the current movement angle always tending towards the home location but not completely rotating.
Without more information of your game world environment it will be difficult to give more advice.