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"

Spawn Ai and move to 1 of 3 locations


How do you spawn an enemy AI, and then make it randomly move to 1 of 3 locations?

Product Version: UE 4.14
more ▼

asked Jan 22 '17 at 12:05 AM in Blueprint Scripting

avatar image

43 25 29 38

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

2 answers: sort voted first

Make your 'enemy' Character blueprint..

Then [Spawn Actor Of Class] using that blueprint type to spawn it into the world somewhere (you can do the spawning from the GameInstance, level blueprint, character, etc)

Having it move can be done a number of ways but the simplest is to just 'tell' it to move move to a place using MoveTo.

Eg. Character with AI Move A black "Character" blueprint (added a sphere so there is something visual to see moving) Added a Variable with 3 locations and a simple MoveTo using one of them at random on BeginPlay.

Nav Remember that you need a Nav Mesh Volume wherever you are going to have AIs moving.


The Result AutoPossess They all move to the 3 locations and clump together.

If your AI aren't moving and have a Nav mesh volume, make sure in their blueprint that under Pawn you have changed it from "Placed in world" to Placed in World Or Spawned.

ai_start.png (41.6 kB)
ai_place.png (114.7 kB)
ai_go.png (118.9 kB)
more ▼

answered Jan 22 '17 at 12:41 AM

avatar image

761 22 7 36

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

In order to better help you, I need you to clarify how you are currently getting the 3 random locations.

Are the 3 random locations actual actors in the world or are they location vectors? If they're vectors, how do you determine the location of each one, do you generate a random location vector?

You can store the 3 random locations/actors in an array within the AI controller or AI pawn and then select a random element from that array and call Ai MoveTo.

more ▼

answered Jan 22 '17 at 12:22 AM

avatar image

689 23 22 54

(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