There seems to be nobody in the forum who can answer my question, so I repost it here.
TL;DR; Can I react to a “is stuck”-Event in Blueprints? If yes, how?
maybe someone can help me out. I have a simple robot AI that moves around the map, patrolling target points. I spawn robots during game play and I have moving obstacles on the map.
From time to time a robot gets stuck. In the log I get, for example:
LogCharacterMovement: BP_robot001_C_17 is stuck and failed to move!
Is there any event that I can catch and do something (e.g. destroy the robot)?
Because I have the feeling everytime something gets stuck the game stutters for a very short time.
Is there any event or property that tells me in blueprints that my actor got stuck? I can’t find any.
Basically just use the Fail output node from the Move To Location/AI Move To function, to detect whether the character is stuck. This condition occurs every time a character is stuck, but also for other failure cases that don’t register in the log, so you might need to be careful when you handle it.
The result pin from Move To Location only results in Failed if the Move To function fails on the frame when it is called. By default this node will rarely if ever result in a Failure unless the pawn or goal is not on or near a Nav Mesh, or the pawn is already at the destination. However, the “standard answer” if you will, is you can call Move To multiple times to course correct throughout the journey, and then whenever it does fail this result should return Failed. If you’re planning on using that type of pattern I recommend using Behavior Trees to call the same function multiple times without needing an advanced degree in Unreal minutia. They are designed to work with Move To and other built-in Unreal navigation support. Also the debugging potential and direct flow visualization are helpful, especially for new designers.
If you don’t want to do this because maybe your AI is simply travelling from point to point without really needing to vary from it or react like a thinking thing (I’m working on an RTS game, was looking for this answer myself when I found your question here, so there are definitely use cases) there are a couple of things you can do.
Frequently call the Move To action and just see if it works, though this isn’t much of a “good” answer as it is a “working” answer when you have an otherwise event driven AI.
Isolate the cause of the failed Move To calls and determine specific environmental factors that are leading to the breakage. Can they get off the Nav Mesh? Is every goal at a location they can reach? Check whenever you toggle movement on and off, and know what happens if/when agents block each other from their goal.
Think about your overhead. It is very possible when running a large volume of pawns with controllers for them to skip commands and lose data as you meet / exceed limitations. Relevancy issues, exceeding memory capacity, and other hard/soft-ware limitations could be the source of your problem. It turns out this was the cause of my issues, I was running just over 500 pawns and controllers at one time, and turns out everything is fine if we stay under about 450.
Correct. This is a community helping here. If you need Unreal Engine developer’s help. You will need to buy a license for UDN (Unreal developer network). I had same issues unfortuantely.