AI Perception Sight allowing for seeing behind

hello all. enemy can see me 360 degrees. whats the problem here? can u help me? its about my services or what?

Hey!

It appears your AI technically can’t see your player anymore but the Blackboard still has a reference stored to it.

Make sure to set/clear your player key whenever your AI Sight senses a new target.
Common practice is to set the “Max Age” for your sight stimuli to a value > 0.
This way your AI will “forget” the player when he hasn’t seen him for the duration of “Max Age”.

Additionally you can use the Gameplay Debugger to have a visual representation of your AI’s perception that will help you to further analyze where the issue might be.

1 Like

As I understood: You want enemy to be able to see you behind the walls as well?

If that’s correct 2 ways to go,

  1. You can change walls collision channel to ignore visibility, since default AI sight works on ECCVisibility.
  2. You can create a new sight UAISense class and override ComputeVisibility()'s trace channel or response to handle sight custom

	ECollisionChannel DefaultSightCollisionChannel;

I think he was referring to the opposite.
He said the enemy can see him 360° but his Sight Config has a vision half angle of 45°.

1 Like

I don’t want enemies to see me through walls. But I want them to see me when I enter their field of vision, just as a normal human would see me. After enemies see me at the last point, they wait for 2 seconds and then continue walking to a random location.

i added ai perception only from blueprint. should i add from code too?

i create child blueprint class from AIC_enemycpp

Using CPP is not required.

How do you get the player target in the first place?

Usually you either inject a TargetActor key inside your BT if your perception component gets updated or using an EQS to find a Player which then also gets injected inside a TargetActor key.

Using raw vectors for targets is rather not optimal as it doesn’t define any state.

yes i got keys here.

Yes I saw those. But these are all just Vector keys.

Its better to use object (actor) keys for a TargetActor.
That key can be used to set and clear a reference to the target of the AI based on the perception.

Once you have a valid TargetActor key inside your BT, you can resume your logic as before.

E.g.,

TargetActor = Reference to the Target

MoveGoal = Cached location the AI should move to, gets updated using the TargetActor

One way to get a target actor is (as said above) using an EQS query inside a BT service and save the target inside your TargetActor key.

The other way would be to manually set/clear the TargetActor using the AIPerceptionComponent

An example (using the AIPerceptionComponent approach)
He destroyed me in the 1v1 but I hope you get the idea :grinning_face_with_smiling_eyes:

2 Likes

yes i got u. when did u make this game lookin cooll :smiling_face_with_sunglasses:

The assets are from the Lyra sample project. Not mine :grinning_face_with_smiling_eyes:
I am just using it for showcasing things here in the Forum.

1 Like

thank u sir.