AIPerceptionSystem: detect by affiliation. Was asked already multiple times, but still not working

*I’ve read all existing replies and articles about the topic. Tried Implementing IGenericTeamInterface on PlayerController and on PlayerCharacter base class as well + numerous experimentations with no success.

Goal: AI perception system to detect other AI character (with the same TeamId) as friendly and A player character (different TeamId) as Enemy.

Here’s a story short:

I am trying to make AI perception detect by affiliation working. So that AI will detect other AIs and a player as friendly or enemy. Was following this short article to implement IGenericTeamInterface, that should allow AI to detect other actors by affinity. By default, AI sees all other characters as Neutrals.

I’ve created a small third person project, where I did all the setup and modifications for Controller classes:

https://drive.google.com/open?id=137…t_nGZQGyHVLSmV

I did exactly what was in the article, and here are all code changes, that I have applied are these:

  • Created new AI controller class, derived from AAIController with some additional functionality that adds TeamID and GetRenericteamID() function.
  • Created new Player controller class and implemented IGenericTeamInteface there.

AI controller “should” (and this is my assumption from what I have learned about Generic team ID implementation) cast to IGenericTeamInteface perceived actor’s controller, and then simply compare TeamId values. If values are the same, it is supposed to mark other characters as friendly, if they are different, as enemies.

Unfortunately this never gets called. AI Perception system always detects all actors as Neutrals, no matter what I do. I see that TeamID is being assigned on construction for both controllers, but it never gets into consideration by AI controller. I was looking into code, but I do not see the cause of the problem.

Would really appreciate any help!

Thank you,
K

That is strange, then again, i never used the AI perception team system, made my own team system and made AIPerception use that.

Hey Kaos,

Well, I’ve decided to post this question because I am almost ready to give up and write custom system, so that AI Perception will generate an array of all perceived artists and other custom code will filter and sort, and assign appropriate enemy type. But there are a few reasons I don’t think its the best approach:

Firstly, AI perception goes thru all actors that AI character perceives every time, and only then I will be able to filter them on enemies, friendly, etc. Where “Detect by Affiliation” suppose to filter actor before passing array any further (more optimized?).
Also there is lots of logic already made for using Friend / Enemy / Neutral already, from what I see, for example: GetAllHostileActors, etc. Which is very handy.

I think this is a very sophisticated system, and it is already written, so by trying to custom write code that does the same thing, I feel like I am re-inventing a wheel…?

Hope it makes sense.

Thanks,
K

Hi…
Did you ever figure this out?

Hi,
Actually I did! I think my issue was that I was trying to implement TeamID directly within character code, when it should be implemented within AIController instead. I am not 100% sure, need to double check my code, but I believe after I moved logic to Controllers, everything started to work as intended…

Hope this is helpful.