Enemy Encounter?

Alright this might be a lot to ask but I want to know how could I make a system where if an enemy sees me it’ll run towards the player (or the player can go up to the enemy) and start a fight, but, the player can run away and eventually the enemy will stop following the player. Also how could I switch the animations to the fighting animations if a fight starts, and when its over switch back to the regular animations. (couple of examples: https://www.youtube.com/watch?v=td4BEDjE8lI&pp=ygUYcmFuZG9tIGVuY291bnRlcnMgeWFrdXph https://www.youtube.com/watch?v=2cWiSY8osx8&pp=ygUUeWFrdXphIGtpd2FtaSBmaWdodHM%3D https://www.youtube.com/watch?v=c3nKcaUqXII ) Thanks in advance.

My first thought would be probably behavior trees or state trees I’m not sure about the animations I’m sure there’s a way to change them in your animation blueprint or something but for the AI behavior you’ll want to look into one of the above options

1 Like

You’ll have to do a LOT of research, but to trigger fight animations, you’ll want to have a flag/variable that let’s the character’s blueprint know that they are now engaged in a confrontation.

An example would be:

BP_Enemy → “Sees player?” (TRUE) → “Player in range?” (TRUE) → ATTACK!

ATTACK! → Set “Attacking player?” = TRUE

BP_Player: “Attacking Player?” = TRUE? (TRUE) → Set “Initiate Battle Stance?” = TRUE

ABP_ThirdPersonCharacter: State Machine → “Initiate Battle Stance?” (TRUE)

→ Run ANIMATION GRAPH logic for combat.

It’s worse than it sounds. You have a lot of work to do.

You can check out Matt Aspland:

Gorka:

And for an in-depth look at STATE MACHINES, Ryan Laley:

2 Likes

alr thanks for that! (love all 3 of those guys btw😭)

2 Likes

alr thanks! @Spacemarine658

1 Like