How to set value of AICharacter on begin overlap?

I have a static mesh with collision sphere attached to it. as the AICharacter overlaps it. it should understand which AI overlapped it and set its value. Assuming all AIs have same variable.

Question is how this begin overlap will understand which AI Actor overlapped it in order to change the value…??

Your assumption that all AIs will have the same “variable” is actually not correct. The game assigns a unique reference to each Actor as it is spawned. So if you spawn 10 Ninjas - one of them probably has the name “Ninja_C08” or whatever.

When you setup the OnComponentBeginOverlap function, the very first pin called “Other Actor” is the thing that touched your collision sphere. This could return the name of any actor though - the player, a bullet you shoot, a physics barrel you kick into it, AI ninja #8 - so the smart thing to do would be to try and Cast this other actor To your AI type - and if that’s successful, then store Other Actor into the variable you talked about. If it fails, ignore that overlap event.

As an added note, any blueprints that you create based off the AI type will also pass the Cast test, as most people would expect. Just a good note.

so basically there is no way to set the value in my AI character without casting it to that specific one!

If I were you, I would first create a parent class of AI that all the rest of your AI characters derive from. That way you only need to Cast to that parent but can return a reference to any sub-type. Also helps for having one place to store any code or variables they all use anyway.

wow seems like a great way to do this. can you tell me how can i create a parent class?