How come In I need a delay node to get AI MoveTo to work?Is there a better solution?

I have AIMonsterController and AI_Character. AI_Character has set AIMonsterController as it’s AI Controller.

The AI MoveTo does not work. Get Player Character returns “Is Not Valid” when called from Event On Possess but if I add a delay node, it works.

How come I can’t Get Player Character? What is the solution for this? The delay node looks like it might be sloppy code(if that makes sense), what is best practice to wait for Player Character to be available? I assume my Event On Possess or BeginPlay(In AICharacter) is being called before Initialization of Player character?

I also tried this code in AI_Character as well and I still need a delay node however the execution makes it all the way to AI MoveTo>On Fail pin. I think Get Player Character & the pawn is valid when called from AI_Character. And of course I don’t run any code in my AIMonsterController when I run this code in AI_Character.

Sorry for the long text but Thank you very much for reading.

If your AI Char is already placed on the level map, it begin play will most likely load in priority before the Main Char.

You will need to change the scenario on when to chase the main char, usually it when the main char approach the ai char that it need to start following/attacking the main char.

So theres no way to say “Hey I want the AI to load in and wait until the Player loads in, when the player is ready/loads in, AI should chase the Player.”?

you will need to use event: From main char begin play > look up the specific ai char ref and call a ChaseEvent from the ai char for example.

2 Likes