Download

More Advanced AI Interaction

I currently have two AI’s in my makeshift level, and they can react to player. But I want the AI to do a certain thing when seeing each other, and a completely different thing when seeing the player. How is this possible using the AI perception component? If it isn’t possible using the AI perception component, how can I do this?

You set them up with componant tags so player is tagged as player and your AI is set up as team1 or something like that. If you have factions you can name it that. Then act accordingly in your behavioral tree and blackboard…

By your lack of mentioning a behavior tree I’m guessing you just have a perception component and move node in blueprint, which you can do but is not how you should properly be implementing AI in UE4. Do some tutorials on Behaviour Trees

List of things:
Behavior Trees
Interfaces
Blackboard
ENUMS

Those are the simple things you will need.
Enums for giving the AI who is who. You can create an enum called PersonType with the variables of enemy, friend, ally, etc.

I would have it check the other’s enum to it’s own to see if they are friends. It’s complicated. If he’s soldierA and I am soldierA, then we are allies, if I’m B and he’s A, we are enemies.

Interfaces allows you to send call function/events on other blueprints without casting to it.

Thanks for the help HuntaKiller, but I am using behavior trees

Thanks for the help, I’m gonna try that later today, then get back to you

Welcome :smiley:

This is very interesting, I kind of see where you are coming from, and have been playing around with enums. But I have a lot of questions. Is there anyway you can explain more?

What do you want to know exactly?

Not much sadly. I know about enums, and mostly how to work them, and I can see your concept in my mind. I have basic knowledge about BT and BBs, but nothing too advanced. However Iterfaces are the death of me. I just can’t work out in my mind how to accomplish what you were talking about. I know that I’m a noob when it comes to Unreal Blueprint coding, but I’m hopeful to learn more. Can you help?

Ok, Epic left out some info about interfaces or it’s hard to find.

TIP: If you create a function inside an interface, it will be available as a event(like a custom event).
-Anyway, I would create a interface function with a enum output link. Then, in BP that uses it, create an enum variable and connect it to the interface function enum output.
-When you call another’s interface function you need to have a target. The easiest way is to use a overlap collision and use the actor it overlaps as a target. Anyone who calls that interface function can get the enum.

I wish I had images. lol.