The Easiest Way to Make a Simple Enemy AI in Unreal Engine 5

Gorka Games
5 Jul 202215:40

Summary

TLDRIn this concise tutorial, learn how to create a basic enemy AI in Unreal Engine 5. The video covers the process of setting up an enemy character, adding vision-based detection, making the AI follow the player, and implementing animations for movement. It also demonstrates how to incorporate a simple attack mechanic and stop the AI when it loses sight of the player. The tutorial is aimed at beginners, providing essential techniques to get an enemy AI running smoothly, with room for further expansion in future tutorials covering advanced topics like health and behavior trees.

Takeaways

  • 😀 Create a new Character Blueprint for the enemy AI in Unreal Engine 5, which allows for basic movement and interaction with the player.
  • 😀 Add a Pawn Sensing Component to enable the AI to detect the player based on sight, with customizable parameters like hearing and field of view.
  • 😀 Set up a boolean variable ('IsSeeingPlayer') to track if the AI sees the player, triggering actions like following and attacking.
  • 😀 Use the 'AI Move To' node in Blueprints to make the enemy AI follow the player once it detects them.
  • 😀 Set up a NavMeshBoundsVolume to define walkable areas where the AI can move, ensuring it has proper navigation paths.
  • 😀 Create an Animation Blend Space 1D to transition smoothly between idle, walk, and run animations based on the AI's speed.
  • 😀 Set the AI's maximum speed to 600 to match the character's walking speed in the blend space.
  • 😀 Design an Animation Blueprint to link the character's animations to the movement speed, allowing animations to blend automatically.
  • 😀 Add an attack mechanic by using a boolean variable ('CanAttack') and an animation montage to trigger attack animations when in range.
  • 😀 Implement a system that prevents the AI from repeatedly attacking, using a delay that corresponds to the attack animation's duration.
  • 😀 Ensure the AI stops moving and loses track of the player if it cannot see them, and resumes behavior once the player reappears.

Q & A

  • What is the first step in creating the enemy AI in Unreal Engine 5?

    -The first step is creating a new Blueprint for the enemy AI. This is done by going to the Blueprints menu, selecting 'Blueprint Class,' and then creating a character Blueprint, as it provides the ability to move and includes necessary components like a capsule.

  • Why is the Pawn Sensing Component added to the enemy AI?

    -The Pawn Sensing Component is added to allow the enemy to detect the player or any other character in front of it. It has properties like hearing thresholds and vision angle that can be customized to determine how the AI detects the player.

  • How does the 'Follow Player' system work in this AI setup?

    -The 'Follow Player' system works by checking if the AI sees the player. If the AI detects the player, it triggers the 'Follow Player' event, which tells the AI to move towards the player using AI movement commands in the Blueprint.

  • What are the two methods for making AI movement in Unreal Engine, and which one is used here?

    -The two methods for making AI movement are using Blueprints or Behavior Trees. In this tutorial, Blueprints are used as the simplest way to control AI movement, though Behavior Trees offer more advanced functionality.

  • What is the role of the NavMesh Bounds Volume in AI movement?

    -The NavMesh Bounds Volume is used to define the area in which the AI can move. It calculates possible movement routes within the area, allowing the AI to navigate and avoid obstacles effectively.

  • How is the AI's animation system set up in this tutorial?

    -The AI's animation system is set up using an Animation Blend Space 1D to blend between idle, walk, and run animations based on the AI's speed. An Animation Blueprint is then created to control the animations based on the character's movement speed.

  • What is the purpose of the 'can attack' variable in the AI's combat system?

    -The 'can attack' variable is a boolean that determines whether the AI can attack the player. It prevents the AI from spamming attacks by setting the variable to false while an attack animation is playing, then resetting it to true after the attack animation finishes.

  • How does the AI know when to stop following the player?

    -The AI stops following the player when it no longer detects the player. The 'is seeing player' variable is set to false when the AI loses sight of the player, and a branch is used to stop the AI's movement if the player is no longer detected.

  • What is the significance of the 'stop movement immediately' function in the AI's Blueprint?

    -The 'stop movement immediately' function is used to stop the AI's movement when it loses sight of the player. This helps ensure that the AI doesn't continue chasing the player indefinitely after the player goes out of view.

  • What additional functionality could be added to the AI based on this tutorial?

    -Additional functionality could include making the AI capable of hearing the player (not just seeing), adding health and damage systems for combat, and implementing more advanced combat animations and behaviors using Behavior Trees.

Outlines

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Mindmap

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Keywords

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Highlights

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now

Transcripts

plate

This section is available to paid users only. Please upgrade to access this part.

Upgrade Now
Rate This

5.0 / 5 (0 votes)

Related Tags
Unreal EngineAI ProgrammingGame DevelopmentAnimation BlueprintEnemy AIBlueprint TutorialAI BehaviorGame DesignUnreal TutorialBeginner GuideCharacter AI