Enemy Will Only Chase Player on One Specific Overlap

I have these cop enemies who will chase the player when the overlap a “trespassing box blueprint”. For whatever reason, the only chase the player when the player enters ONE SPECIFIC box. If I have multiple, none chase the player in any of the others. Why is this?

I used Booleans that set trespassing True or False. That indicates wheats there’s an “AI move to” active or not.

How are you passing the information to the ai’s blackboard to set the bool?

Are you gathering the AIs that overlap the trespassing box and setting their blackboard bool directly?

I’m not using blackboards. I am going a simpler approach with blueprints.

I have the “trespassing box” below.

Then the Police Character BP

The problem lies within the fact that you are using Get Actor Of Class “Trespass Box”
You are only getting the 1st box in the level that unreal finds & not the closest to the policeman.

So you are triggering a box probably half way across the level.

You should reverse the logic. Upon entering the trespass box you should do a box trace with the extent of the trespass box and filter by Police men. Then all found police men should have their bool checked to be “on alert”. Then once they see you if the “alert” bool is on then they should chase you.

Do how may that look? A box trace in the “trespass box” on “beginoverlap” casted to ‘fpscharacter’?

How would I filter it to just the police nearby?
And would I keep the “AI Move To” code in the police bp, just the boolean changes?

(This is new to me and I’m trying to figure it out).




And in the police officer

It’s basic logic, but it will become hard to manage in time

I would highly suggest looking into blackboards and behavior trees.

It will not show the Print String, and the line trace appears very small. I’ve messed with the size but it didn’t seem to do anything.


image

You just need to go into the box collision component & set its extent to something bigger.

Alright, it now overlaps the police, but the print string won’t appear. There seems to be something that won’t let it go through.

My Code for the Trespass Box

If in my PoliceBP I changed this to “ALL actor of class” would that also work?

You should remove the interaction with the trespass Box from within the police actor. He should only receive the information.

You could also use a delegate to bind the police offices within the traspasser box to listen for a delegate call from the box.

So you’re saying to remove this here?


(I’m still trying to learn and figure all this out).

Yeah, you don’t need that information in the police actor. Just send him a message if his bool to chase you should be on or off.

Let the trespasser box send it out. The character should be ignorant of the box’s existence. That way you can trigger him with other external sources.

That information is important though. If I delete it, the police chase me on sight. What is there now is so if they see me AND I’m trespassing they chase me.

The code you sent doesn’t appear to be doing anything while mine, while broken, is. Even when I disconnect my code to use only yours it doesn’t do anything.
I’m trying to figure out why that is.

(I’ll look into Blackboards in the meantime).