How to make a Enemy in a 2d topdown game

Goodday,

I was wondering if anyone has some sort of tutorial of bit of code that could help me find out how I make a enemy in my 2d topdown game.

Thanks!

1 Like

Hey there @Doeglas! So in Paper2D, unless you’re working in a 2.5D or 2D environment with true height, you’ll likely be handling your enemy AI movement by hand instead of navmesh. Here’s an example:

Disclaimer: One or more of these links are unaffiliated with Epic Games. Epic Games is not liable for anything that may occur outside of this Unreal Engine domain. Please exercise your best judgment when following links outside of the forums.

Thanks! I hope this tutorial can help me figure things out.

This should give you the basic idea, running players and enemies off of the character control system is an easy way to get basic AI running, but if you start needing more complex state changes besides walking, stopping, attacking etc, you may have to get a bit more involved. Many of the 3D aspects of the engine transfer well to 2D but not all of them, navmesh would require a good amount of designing around if you’re using tilemaps to be able to use it. You’d likely implement your own A* or similar pathfinding based on the tilemap instead.

Took me actually ages to make this even though it looks so simple. Finally got some sort of basic 2D A.I. that moves to the player every tick.

1 Like

Can you please explain how you did this as i am also stuck and need help very quickly as i am a student and i need to make this game within 2 weeks. can you please explain how you made it work plsssssss

It’s fairly simple actually:

Step 1. Setup

Create a blueprint class called ‘Papercharacter’. Then open the character movement and change the following settings:

  1. Set ‘Gravity Scale’ to: 0.0
  2. Set ‘Default Land Movement Mode’ to: Flying
  3. Set the ‘Max Step Height’ to: 0.0
  4. Change the ‘Max Fly Speed’ to: 30.0
  5. Change the ‘Braking Deceleration Flying’ to: 3000.0

Step 2. Movement System

On a ‘Event Tick’ node setup this:

The timeline goes from float 0 - 0 to 1 - 1.

Since this Sets the Actor Location the AI will ignore any collisions. If you want the AI to collide with the Tilemap you will need to make a custom collision system.

I hope you can work it out. Good luck! :grin:

1 Like

I got it to work than you sooooo muchhhhhhhhhhhhhh!!!

1 Like

could you tell me how you got the moveTo part i unable to find it .

and also does this work if i made a paper2D charcter bluprint?

MoveTo is a reference to the timeline.
Paper 2D Character is the same blueprint as mentioned in the top message.

quick question playerFLE is a reference to what?
and how do i make the wally node apper on moveTo?

Player REF is a reference to your player blueprint.
Walky is how I named my float. If you open the timeline and make a float going from 0-0 to 1-1 you can name it whatever you want.