AIPerception Hear, Damage and Sight

Anyone can help me?
I am trying to make an AI that Hear the player, See the player and act when get damaged!

I would like to make something like that:

  • The enemy walks randomly at the map with a radious of “450” or something like this number
  • when the AIPerception get updated, the AI starts to follow the player
  • when the enemy cannot see or hear the player anymore he returns to walk randomly at the map

Note: I got an problem creating something like that, when the enemy see another enemy he starts to follow this enemy, i don’t wanna that if it’s possible

I can’t find any tutorials that make these 3 things, if anyone can help me i aprecciated!
I also thanks if anyone can tell me who to set an char as “friendy”, “neutral” and “enemy”

Obs: I am brazilian, so i am sorry if i say something wrong or somehow disrespectful, i don’t practic my english

I tried to set AIPerception with the 3 perceptions that i say before, i set the sight as my primary sense and then i tried something like this to make my enemy came to me, but it didn’t work:

Hi,

I did something similar to you but in C++. Here is the code:

void AShooterAIController::OnPerceptionUpdated(TArray<AActor*> updatedActors){
	for (int32 i = 0; i < updatedActors.Num(); ++i) {
		if (Player == updatedActors[i]) {
			FActorPerceptionBlueprintInfo Info;
			GetAIPerceptionComponent()->GetActorsPerception(Player, Info);

			if (Info.LastSensedStimuli.Num() > 0) {
				const FAIStimulus Stimulus = Info.LastSensedStimuli[0];

				if (Stimulus.WasSuccessfullySensed()) {
					// Player gets inside sight (is visible)
				}
				else {
					// Player gets outside sight (no longer visible)
				}
			}
			return;
		}
		else {
			AActor * Parent = updatedActors[i]->GetAttachParentActor();
			if ((Parent && Cast<AShooterCharacter>(Parent) && !Cast<AShooterBot>(Parent))) {
				// Player has been heard
			}

		}
	}
}

Regarding the damage sense I also tried to make it work but I wasn’t able because there are no tutorials about it. I think it is still a bit experimental. What I did is use the hearing sense to detect when the enemy was shooting and then get their position.

That is almost what i am looking for, but all of my project is in Blueprint… I am looking for tutorials, but i don’t found anyone…

I made it, but there is still the bug that the AI chasing me and another enemys… I wanna just that he follow the players, what should i do?

There is my AIController

I think that (probably) the problem is that you are using a parent class of both (AI and Player) when casting. In the cast you should use the exact type of the player so that the AI will only follow the player ant not the ai characters.

If you look at my code this is what I do with the casts to ShooterBot.

Yes, i think the same, but when i tried to cast to thirdpersoncharacter i realize that i cannot set my var “isChasing” because it’s from my AI_char, then the var stay incompatible

But, you should cast your self controlled pawn to AI_char and the updatedActors obtained from the Perception System to your Player type in order to know if any Player was heart or visible.