Why is AIMoveTo not available in blueprint functions?

I don’t see AIMoveTo as an available action inside of blueprint functions, but the command works fine when placed in the Event Graph. Is this how it’s supposed to work? And if so are there some sort of rules for what can go in functions?

My only guess is that Blueprints with multiple possible execution pins aren’t allowed… but then I’m not sure why if that’s the case.

I read through some of the documentation on functions but didn’t see anything that could be causing this.

The reason is that AIMoveTo works over a time period rather than being fired and done. Functions cant stay on the stack waiting around for the completion of the AIMoveTo or the whole system would have to stop and wait (which wouldn’t work so its not allowed).

–My only guess is that Blueprints with multiple possible execution pins aren’t allowed.–

That is sort of right. To continue execution of the engine, the prospective containing function gets pulled back off the stack immediately after it is done. There is nothing to return to when it would be time to fire success or failure.

that’s why not in functions.

I don’t know much about event handling in ue4 but it is probably done by some managing object that holds a list of existing events which would allow for events to sit there for however long they are needed. The reason AIMoveTo works fine in event graph is because its being encapsulated in an event, which doesn’t actually end until the AIMoveTo comes back with success or failure.

to summarize: Functions must die to return, period. Events can go on as long as they haven’t actually ended.

1 Like

maybe late but your comment made me help to understand AiMoveTo a little bit more.
I was wondering why there is MoveTo and AiMoveTo, wondering what the difference is.

So basically: AiMoveTo is fired over a time period which helps the BehaviourTree, i setted up right in the task, to fire a task where AiMoveTo is used as long as the destination has not reached yet.