Download

Help: How to program an enemy that follows a trail of actors ?

Hi !

I am trying to program something on UE4, with the use of blueprints. I have my player who can move, and he deploys, with a certain delay, little spheres behind him. This spheres are destroyed after a certain amount of time.
What I’m trying to code is that when an enemy overlaps one of these spheres, he starts to follow the trail one by one, until he finds the player, or loses the trail.

Can someone help me on that ?
Thanks in advance !

Hello
I would create these sphere actor first with an integer variable. The actor which is placing the spheres increments and set this variable with every spawning of the sphere.
So the player spawns first the first sphere and sets the variable with number 1, then sphere number 2 with 2, number 3 with 3 etc. You can do this by incrementing the variable before every spawn.
Now, once an enemy overlaps with one of these spheres he can read the number. For example, it is number 2. Now you can simply add one and search the sphere number 3 and get its location and move the enemy to this location, where he, if sphere number 3 still exists can get the location of the next sphere number 4.
In order to get all the spheres you can use GetAllActorsOfClass and then select your sphere alias waypoint class.

Greets

once your Ai finds the first object, have it do a sphere trace for the other objects it needs to find, if it gets a hit, grab that location and move to it, if nothings found go back to patrolling