How can i make a 2d enemy follow me in ue5

Here’s a general overview of the steps you’ll need to take in order to create a 2d enemy that follows you:

  1. Create an AI controller Blueprint that will control the movement of the enemy.
  2. In the AI controller Blueprint, create a variable to store a reference to the player character.
  3. Use the “Get Player Character” node to set the value of the player character variable.
  4. Use the “Get Actor Location” node to get the location of the player character.
  5. Use the “Move To Location” node to move the enemy to the player’s location.
  6. Use the “Set Timer” node to periodically update the enemy’s destination to the player’s location.

It’s important to keep in mind that this is a high-level overview and there may be additional steps and considerations involved in implementing a 2D enemy follow script in UE5.

You can also use other nodes such as “Line Trace by Channel”, “Line Trace Single by Channel” and “Line Trace Multi by Channel” to check if the player is in the enemy’s sight, and if it’s not, use “Move To Actor” to move the enemy towards the player.

Note: you might want to constraint the movement in 2 axis if it’s a 2D side-scroller game.

3 Likes