Recently I’ve been running into a problem with my Enemy Ai code. When I wrote it up the first time and tested it, it worked okay like it was intended. But now it won’t run like I want it to. I have it set up where when it doesn’t see the player, it runs towards a target object and makes it take damage. After I got that code figured out, I started laying out the level. I put the target object inside a circle when I was starting it off. I just finished laying out the level, and decided to run the code. At first, the enemy Ai went towards the object like I expected. But when I now move the target object (even a little bit) it won’t interact with it at all. Even when I either delete or move the circle I placed it in at the beginning, it still won’t run to it. I have nothing in my code about the enemy Ai interacting with the circle at all. Here is a recording and a screenshot of my code asking for it to move towards the target object when it isn’t looking at the player. I have no idea what is going on with it.
What actor is this blueprint from? Also, you seem to be calling AIMoveTo every tick. I’ve never had much success with that. Is your navmesh dynamic? If not, you may just need to rebuild it when you move the target.
So the code is from the the Enemy Ai, and the target has it’s own set of code that starts taking damage whenever the enemy enters it’s sphere collison. Here is my Navmesh. I deleted it and rebuilt it but nothing about it changes. What’s odd is that when I select target object and bring it under the map, the Ai will still start to go after it. But when I put it back, it won’t even move.
You also said about not using Event Tick. I have an Event Begin play, but it’s already occupying a different part of the code. What would be the best alternative for it?
You’re using GetActorOfClass. Is there another “Target BP” in your level that is perhaps out of reach?
I’m noticing your target block is a blocking volume.
So you can try two things.
Try setting your Acceptance radius to at least the Agent Radius of your NavMesh which appears to be around 40 if I’m eyeballing it.
Or
Try unchecking “Can Ever Affect Navigation” in your static mesh component.
Open your static mesh directly and in the navigation section, uncheck “Gather Convex Geometry” and check “Is Dynamic Obstacle”. This should enable the Area Class property. Select “NavArea_Null”.
This will make it an obstacle that other actors will go around, but it won’t displace the nav mesh so you can still get to it.
The second option worked! I selected the static mesh and turned off “Can Ever Affect Navigation” and the Ai is now running towards and damaging it! Thank you so much! 10/10 service, my friend!