How to deactivate pawn sensing on enemy ai from the player bp so that the ai is not able to see the player anymore ?

I’m using a skill where my character goes invisible but the ai can still see him because of the pawn sensing im using. Is there any simple way i can deactivate the pawn sensing for the duration of this skill…

What i try was to cast to my base enemy bp and from it get the pawn sensing component and then setting the peripheral vision angle to 0… Or get “see pawns” and set it to disabled. (If i untick/disable “see pawns” on the pawn sensing component directly on this base enemy bp it then works and the enemy just ignore the player. But when i try it on my player bp it just don’t work…

1 Like

Hey @catz111! You’re going to laugh at the solution I used when doing the same thing.
You can have a bool on the player that says “IsInvisible” then when it’s sensed by the enemy, if “IsInvisible” is true, set the ai’s sensed target to null, and end the line of code.

So if “IsInvisible” is false, they behave as if they didn’t see the player. It feels more like a Jedi Mind Trick since they still SEE the player, they just… decide that they don’t.

1 Like

hey there…

I wish this could work but it’s not right now i guess im doing it wrong…
I set on the player on event beginn play a bool “IsInvisible?” then connected the pawn sensing to it and if true then it is Invisible and if not then not…

and on the skill this bool IsInvisible to true and then untrue both failed

I then try to set on the base enemy bp the same logic on event beginn play then the bool “IsInvisible2” and then calling it on my the skill on the player character I tested both true and untrue nothing worked unfortunatly. Any idea why it is not working ?


Can someone point me out where the code fails to resolve this issue?

Ive done that from the pictures above can you tell me where i have a mistake ? I really want to fix this issue and it couldnt be that hard to somehow deactivate the pawn sensing or some other method like with the bool. But the question is why is it not working to me and what can i do to make it work as you describe?

Hey @catz111!

So you’re going to have to show more of your code, particularly the entire event where the AI would turn off sensing. However, my suggestion is NOT to turn sensing off, but to change their behavior based on if the player is invisible or not.

For a good idea of how that works, think of many games where people are not hostile if you don’t attack. In that case it would be “IsInvisible=T” when not hostile and “IsInvisible=F” when hostile.

Just get us some more of your code and we’ll be able to take a better look. :slight_smile: We need to know when and why the code would execute.

Hi

I have the code on my player character and is a skill. It activates by pressing a key then the skill starts and it makes the character invisible (the material of the character changes to an invisible one). So when the skill starts then the “real” invisibility should trigger in this moment and enemy’s should not be able to register/see the player anymore preferably.

Here is the code of the skill (i removed the previously added stuff with the pawn sensing and the bool).
https://streamable.com/bmvp9q

The skill awso can make the character go through enemies and the best case scenario is when in the moment he gets invisible enemies cannot see him anymore and all the projectiles shoot at him should awso go through him (that should be easy with the projectiles when i just ignore them like i awready ignore the body collision of the enemy so lets not overcomplicate everything. All that matters is just that the enemy cannot see the player anymore once the skill is triggered)…

https://streamable.com/8rcdy7

Are you using standart AIPerception component?

No im acctually using only the pawn sensing component
bandicam 2023-07-14 18-45-15-694

I added the perception as well for testing but my enemy only use the pawn sensing at the moment

I guess you are using OnSeePawn?

And where are those components, inside pawn or controller?

Yes i am using “OnSeePawn” its on my Pawn/Enemies bp in there and nothing on the player controller…

Cast from Pawn output to your player character and get IfInveseble? from cast.

Can you explain that or give an example how this should look like i dont understand it…

I try that but its not working the enemy can still see the player the only thing that make them stop to see the player is if i uncheck in the pawn sensing “See pawns”

If i then connect this pawn sensing at event beginn play and then set it and uncheck the “see pawns” nothing happens the enemy ai can still see the player…

If i go and try to get this paws sensing from my player character and set it on my skill to “see pawns” to false it awso does nothing …

I awso have this boolean “IsSeeingPlayer” it awso does nothing

On event beginn play i set what this “IsSeeingPlayer” boolean is. It should if true The SeePawns should be activated and on false Deactivated… But as it seems i have no access to this “See Pawns” in the Pawn sensing… It only works if i click on the Pawn Sensing and manualy untick this “SeePawns” then the player is invisible to enemies…


First.

You made an error.
Going from what you said and picture, you are not setting “see pawns” to false in component, you are setting your custom variable “See Players”.

Second.
You don’t need to make your AI blind. All you need, using my example, execute your code “on see pawn” that you allready have if “IsInvisible” set to false.

True thats why i edited the post above befor you post this one and i added a second screenshot where i do not use the boolean. On this one i didnt use the bool but directly get it from the pawn sensing…

I’m trying that but the “IsInvisible” does nothing as well i can set both to true or untrue the enemy does aways the same. I can completely delete the “Is seeingPlayer” and they do aways the same. If i got in the collision radius of this pawn sensing they see the player and go chase him if i go out of the collision then they continue going to a specific location. If i have there is seeing player or delete it it does not change anything on the behaviour. So how can i implement my code there ? I have my skill on the player BP…

If i define the “IsSeeingPlayer?” (and yes i do not use my boolean but i get it directly from the pawn sensing) then i define it to disable the pawn sensing when the “IsSeeingPlayer” is false

Anyway i need this to call it from my skill on my player bp where the skill is located but i cant cast directly to the enemy or the skill doesnt trigger if i do cast to enemy…

I need it here somehow

No, you don’t. You can do it, but it is a bad solution.

What you need to do is to create a bool variable. When player goes invisible you need to set it. And when AI executes On See Pawn cast to player and chek this variable.

You need to create bool inside players charecter.

Ok so i set new variable on the skill directly “Is Invisible Skill” to true and in the end of the skill i set this to false. Then i go to my enemy bp and cast to my player from it i get the bool Is Invisible Skill and if its false then enemy see the player but if true then the pawn sensing is deactivated / or not deactivated but using the old bool on the enemy “IsSeeingEnemy”

Here the bool on the player


in the end of the skill

and on the enemy

Like this the enemy just ignore/don’t see the player even if i don’t use the skill.

Is this how you mean i should do and if not how or what to do ?

Is On Pawn See executing?