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…
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.
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…
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 ?
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?
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. We need to know when and why the code would execute.
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)…
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…
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…
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…
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.
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”