I made a simple ai which shoots at enemies and turns around towards them. The problem tough is this companion ai only shoots when the player character is around 5-6 meter aways from it. When i come close to it then it just stops shooting and reacting to enemies at all. So i have to step back 5-6 meter and it starts shooting and reacting to nearby enemies again. Which is wierd and i am not sure what is causing this. The bp is very simpel there is no collision boxes set up or anything…
Here is the pawn sensing settings and the whole bp
Hey there @catz111! It doesn’t seem logic wise that anything is getting in the way of execution, so let’s step through and see if the player’s collision or something my be getting in the way of the pawnsensing checks.
First make a print behind PawnSensing that prints what it sees (before the cast to enemy), and verify it can still see enemies while the player is near.
When i spawn this companion ai it starts to print string correctly all the nearby enemies and it shoots at them. When i come close to it then the print string stops and shows nothing and the ai awso stop shooting. Is like completely deactivating it when im near it. Has this something to do with collisions settings maybe ? I try to ignore the player collision (on the capsule component as well as on the mesh) but it has no effect…
Looks like this is the part where it is not working. Getting away from the companion ai makes it print string correctly all nearby enemies but when getting close to it then everything stops. No print string anymore and no shooting… (acctually staying behind it nearby then there is no print string and nothing. But the ai can register the player character when im close to it and face it - but only the player character no print string on any enemy even if they are near it as well)
Edit: The default class of this ai is character. Is this the correct one i should use for an ai like this ? My player character is awso a “character” class and it intervene the actions of the ai as it seems not that i maybe need to change the class of it ?
Here are the current collisions settings i’m using on the mesh and capsule component (both are exactly the same)
Yep, that was the proper test, and it’s quite odd that it doesn’t see the player, but loses sight of the enemies. I’ve been trying to replicate this with just pawn sensing and some dummy pawns, but in my tests the pawn sensing can see all targets in the cone and isn’t blocked by the player at base. Are there any other events that are affected by player proximity going on that could be taking precedence over the event?
Yeah the player character has 2 more sphere collisions which i didn’t think could stop the ai from seeing the other pawns or interfere with it… But it turned out it can. The sphere collision had under the collision setting set to “block” “visibility”. Just changed it to “ignore” and now everything is working.
But this collision is set to only overlapp my enemy with tag so not sure why it counts as an enemy where it has no tag on… Awso this same sphere collision overlapp only “physics body” and my companion ai is set to world static (is an ai where it should not move anyway) preset and should not interfere or at least i tought it wouldnt…
Anyway ty for the help your last comment made me find the failure.
No problem! The reason the sphere collisions covered it was because they take the collision properties of their parent, who would usually be detected in this case so it led me to believe there had to be other collisions attached to the character.