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?
asked Jan 22 '17 at 12:05 AM in Blueprint Scripting
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. 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.
Remember that you need a Nav Mesh Volume wherever you are going to have AIs moving.
The Result 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.
answered Jan 22 '17 at 12:41 AM
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.
answered Jan 22 '17 at 12:22 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here