Top-Down Engine - Core Game Mechanics

Good to know: Both the Platformer Engine & Top-Down Engine share a lot of functionality. and a lot of times the same techniques can be applied to both engines.

Core Game Mechanics

The Top-down plugin is great for RPG-style games so we am going to create just that. An RPG.

And for that we am going to need a character that can:

  • Walk

  • Jump

  • Use Melee attack

  • Use Ranged attack

  • Get Damaged

  • Heal themselves

  • Die

A lot of these features are already coded in the plug-in as individual components, but you can also code these systems with blueprints if need arises.

First things first, let's…

Creating our character

Go to the folder where you want to add your character. Right-click the content browser or click on Add to add a new blueprint. Click on Pixel2DTDCharacter to create your own character.

By default, you can notice a few main components in your new character.

The Arrow Component is merely a representation of where the character will be facing when the game begins. You will see a similar arrow on the player start, showing which direction the player will be spawned facing.

The Pixel Component is the face (and body) of your character. And that face will be the flipbook that represents your character.

To create that flipbook, first Import the images you need into your UE5 project. Then Right-click on the sprite sheet and go to Sprite Actions → Apply Paper2D texture settings. This gives your pixel art the required crispness.

Next, Right-click it again to go to Sprite Actions → Extract Sprites.

Once you have the sprites you need, select the sprites that make up one animation (in my case, one for the test sprite). Right-click and Create Flipbook.

Name your flipbook and make it your character’s source flipbook. It should look something like what you see below.

Since this is a top-down game, we want our character to be visible from the top-down (duh). We are going to add a Spring Arm and Camera so it’s the child of our Pixel Components.

Spring Arms aren’t required in 2D games as their main function is to change the position of the Follow Camera when a 3D object gets in the way. However, they are great to visualize the camera position and make Zooming in easier (by just changing the Target Arm Length). However, then you should go to Spring Arm, and in details go to Camera Collision → Do Collision Test and uncheck it.

Then I am going to rotate our Pixel Components so its facing up, and adjust our Spring Arm and Camera as required so it looks like this.

The next component we need to look at is the Capsule Component.

The Capsule Component is in charge of character collisions. Capsule colliders are used by default as they are the best colliders within Unreal for movable characters (unless you are using plugins like this).

We need to position the flipbook on the Capsule Component in such a way that the “legs” of the character are covered by the component but not the rest of the body. Placing the collider this way can also allow the character to go in front of objects without bumping into them in an unnatural way. Adjust the collider radius and half height based on your own character’s design and function.

Now we want to make sure that every time we test the game, our player shows up in the game, and not the Default Plug-in Player. So we are going to go back to Project Settings→ Maps and Modes and change the Default Pawn Class to the character we am using.

We are also going to add a Tilemap (you can go here for more detailed steps on how to add it). After every few steps, we play the game to make sure the character is visible in case we need to troubleshoot.

Now we can jump in and work on the mechanics.

Movement Mechanics

TO BE ADDED...

Last updated