Hi everyone!
You guys may think that this is an old problem, but i tried many solutions. Here is the problem
I have a NPC that is running toward a goal (EnemyBase1) with “Somple Move to Actor” with the Event Tick, like the image below, with a boolean variable to cut it off when needed:
But then he sees a target on the way to there (using Pawn sensing) and it set the boolean that is on the Event Tick Branch, so he could forget that main goal and go after target.
The thing is, he is not stoping the EventTick code when i set the “SawTarget” variable, cant seem to know why. Any hint? There is a mistake there that i can’t find? Would apreciate any help.
Thanks!
Event tick runs EVERY FRAME. That event is being called 120 time per second.
By the time your AI decides to stop, it’s too late, you’ve already built up about 10,000 calls to SimpleMoveTo and it’s never going to stop.
SimpleMoveTo only needs to be called ONCE for the character to make the move
So when decide to pursue, just call the move to then.
Hmm, so it accumulate, that is something that i wasn’t aware of that. So i tried to put a “Do Once” in the “Branch” place, but the NPC stood still this time
Any hint?
The take away from this is ‘things you only need to do once don’t go on tick’
Put it on a custom event and call that event when you want it to happen.
Roger that, thanks!! Will make a different aproach and respond if i got it to work or not at all
(Im a Mechatronic Engineer, so we usually use a lot of clocks for servos)
I think you have it on tick because you just want it to happen, right.
If that’s the case, just put it on begin play instead
Actually, i wanted to have an action on standing by when others have already been done, i was relying on tick for that. So i decided to make a code on pawn sensing to check when the AI is not seeying anything, than he will get back to pursue it’s goal.