x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.21
Tags:
more ▼

asked Feb 24 '19 at 12:20 AM in Blueprint Scripting

avatar image

MrBubblesLIVE
3 1 3

avatar image ThompsonN13 Feb 24 '19 at 02:45 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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.

more ▼

answered Feb 24 '19 at 06:11 AM

avatar image

mrteuy
146 2 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

alt text

alt text

moving.png (283.4 kB)
more ▼

answered Feb 24 '19 at 07:05 PM

avatar image

MrBubblesLIVE
3 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Feb 24 '19 at 07:42 PM

avatar image

mrteuy
146 2 2 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question