Hey! does anyone know how to make a simple 2d enemy follow script with blueprints?
i have not found anything after hours of searching that worked.
all im trying to do is get another actor to move towards the player?
Hey there @PatyPotato! There’s tons of ways to pull this off, however to answer the question, I first have to ask. Top down 2D or Sidescroller 2D?
Sidescroller 2d, I have tried many ways but most will not even cause the enemy to move, I am going to restart an enemy later so i meothod would be appreciated.
P.S the enemy is a flying enemy
sidescroller 2d
Here’s a general overview of the steps you’ll need to take in order to create a 2d enemy that follows you:
- Create an AI controller Blueprint that will control the movement of the enemy.
- In the AI controller Blueprint, create a variable to store a reference to the player character.
- Use the “Get Player Character” node to set the value of the player character variable.
- Use the “Get Actor Location” node to get the location of the player character.
- Use the “Move To Location” node to move the enemy to the player’s location.
- 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.