I’m busy learning my through UE4 atm. I’ve a simple ai that goes from point A>B>C etc… Until it reaches the final point. This is working fine with placed actors and actors spawned with a “direct?” function call. However, when the spawn function is called from a timer the spawned actors don’t move.
The first call to SpawnEnemy spawns an actor and it moves, the calls from the timer spawn the actor, but they don’t move. I’ve had 3 - 4 placed in the world manually and they all move fine, including the one spawned from the non-timer call. If only the timer is called, nothing moves.
We had issues with AI spawned via timers and the perception component.
I wonder if this is similar.
I’ll pass this link onto our AI guy (@zoombapup).
Hopefully he can chime in with an actual fix for you.
Your best bet for this kind of thing, is to break out the “Visual Logger” and see what the AI is doing (or failing on).
The other thing is to make sure you check all of your values by adding a breakpoint at all the parts which could affect the move call. So specifically, add a break on the moveto and hover over the inputs. Do they seem sane? Is there actually a move target etc.
If the move is failing, it will show up as a fail in the visual logger, usually with a bit of help on WHY its failing. That should help you figure it out!
Thanks for the response. I’ll do some more debugging when I get home tonight.
From the debugging I’ve done I found that “Get Controlled Pawns” returns an empty/null value. Self and CP seemed to be fine. However, you have a good point. I’ll do some sanity checking :D.
Okay, I’ve had a look at the values when it breaks on the Move To function. The Pawn is None. The visual debugger is also showing Pawn as None for MyAI_C_1 (or something like that). MyAI_C_0 has a Pawn and also had a pawn when the breakpoint was reached on the AI Move To function.
Now no actors moved, and first break had the same Pawn = None issue. So it would seem for some reason the AI isn’t possessing the pawns when a delay is involved?
Just to make sure I wasn’t insane I did two spawn calls without a delay.
It is definitely some timing issue. The move function is called before the pawn is possessed… So instead of using Event BeginPlay I used Event OnPossess.