How to get an enemy AI to run to a spot on a plane in the map

I have enemies spawning in a certain spot, but I want them to go to a specified area on the map(in this case a plane). How do I get the location of a plane onto my enemy BP?

you need a way to reference the plane. some ways to get a reference would be to use overlaps, traces, or public variables, but those options are probably not suitable in this case. its really going to depend on the situation but theres always something like the get all of class then use logic to decide which to use, for example get all of class then have a script which finds the closest plane. another option would be to have a reference to the location to move to stored elsewhere and have the character get it from the stored value, an example of this would be storing a reference to the plane in the game mode then in your character on begin play get the stored value from the GM.

theres many ways to approach the issue but its going to depend on your situation.

I think you need to ask 2 questions - how to move an AI and how to pick a point to move to.

For moving the AI, Move To, Move Directly To - either in blueprint or in a behavior tree, are the easiest. Manually, you can interp along a vector directly from point A to point B.

For determining a position, there are functions like Point on to Plane, or you can trace a line downward to find a point.

My solution was having public variables for the World Location and the Scaled Box Extent. Then using those in another class to find a random spot for them to move to.

The way I do is to call Get Random Point in Radius (use Get Navigation System node pin to run this), to determine a point on the navigation mesh, then use a bounding box extent to narrow down to a rectangular area. This, of course, requires a navigation mesh, but seeing as your want AI to walk around I assume you are using one already.

You can make small adjustments to your code you already have there. If you didn’t go that route, you can add on after the random point to regulate the coordinates in the X/Y plane and hand-set the Z for height of the point, or start in the air and trace a line downward to find the point of intersection for the Z coordinate.