Is there any way to have pawn sensing exclude specific classes of pawns?
I have an RTS camera character class that the player controls. I also have AI controlled character classes. I am working on the AI behavior, and I set it so that these AI controlled characters will follow each other when they sense each other via pawn sensing. However, they were only sometimes following each other and I realized that this was because most of the time they were focused in on the camera character that the player controls. Is there a way to set pawn sensing to ignore certain classes of characters?
I've tried unchecking only see players, but this doesn't entirely ignore the RTS camera, i.e. when the camera is still in the pawn sensing range it will take precedence over other pawns. I have also tried comparing the pawn sensed with the object equal method, and preventing action if the pawn is the RTS camera but to no avail.
asked Jun 25 '18 at 08:02 PM in Blueprint Scripting
I think I found a method that works for now (although its viability may change depending on if my functionality changes in the future) but here it is (it's actually quite simple and I feel pretty stupid for not thinking about it):
Basically I just grabbed the pawn return node that the pawn sensing event returns, and get the class. I then compare it to the class that I want it to sense (in this case it is its own class so i just set it to self) and then return the bool and have a branch from there. https://i.imgur.com/O41arEK.png
I think for now this works fine as I can also alter the bool expressions so that it can be exclusive too and not just inclusive.
answered Jun 27 '18 at 06:31 PM
I'm sure there are several different ways to do this but, when I was testing around with trying to make factions and stuff I was just checking targets in range for if they had a tag or not.
You may also just be able to disable collision for your camera with 'visible' so it no longer triggers as something to be sensed. You may need to be careful about how your sound in your game is produced like that though.
Personally I'd just use the tags as you can also use them for other things but it's probably not the most efficient way.
Hopefully someone else can provide a better solution.
answered Jun 25 '18 at 09:04 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here