
A brief look at what to expect over the content of this video course.
Finished versions of the course assets and scripts downloadable below!
Music: Summer Ambient Piano by Rafael Krux
Free download: https://filmmusic.io/song/5504-summer-ambient-piano
License (CC BY 4.0): https://filmmusic.io/standard-license
Artist website: https://www.orchestralis.net/
Explore a quick crash course in building a top-down 2D action RPG in Unity, using the mystic wards asset pack and starting a new 2D project in Unity Hub.
Set up a pixel perfect camera and upscale vendor texture, then create a multi-layer tile map with a grid, tile palette, and colliders, adjusting order in layer for player rendering.
Install and enable the new Unity input system, create a player input actions asset, attach a player input component, and implement an on move handler using fixed update for movement.
Learn to implement top-down movement in Unity with a kinematic Rigidbody2D and BoxCollider2D, using casts to detect collisions and move with a defined move speed and fixed delta time.
Adjusts collision offset to align with fences and implements axis-separate movement via a try_move function, enabling sliding along walls by testing x then y directions.
Install Cinemachine, add a virtual camera to follow the player, and apply the pixel perfect extension to smooth motion.
Create a sword hit box as a child with a trigger box collider and enable it only during attacks, using a sword attack script to manage right and left offsets.
Define an enum for attack direction (left or right) and use a switch in the attack function to trigger left or right sword attacks, synced with sprite flip in Unity.
Create a slime enemy and implement sword hit detection using a trigger box collider to deal damage, track health, and defeat the enemy when health reaches zero.
Build and apply a slime animator in Unity, create idle, damage, and defeated clips, and use a defeated trigger and an animation event to remove the enemy after defeat.
Wrap up the first part of this top-down 2d action rpg crash course in unity, covering player movement, collisions, and tile map setup, with slime damage as a next step.
Downloadable in this video is the starting point for part 2. You should download it to follow along in this part.
Read the movement input vector and apply it to a dynamic rigidbody, clamp speed, flip the sprite when idle, and set animator parameters to switch between idle and run.
Connect the idle and run states in the animator to switch to run using a boolean is moving, enabling instant transitions for a top-down 2D action RPG in Unity 2022.
Plan attacks with a one-time trigger from the Unity input system; bind fire to left mouse or right control, then trigger a sword attack in the animator and lock movement.
Set up a slime enemy in Unity by creating a sprite prefab, adding dynamic Rigidbody2D with gravity off and collider, and wiring an animator controller with idle, run, hit, death.
Tune slime and player physics in Unity 2022 by adjusting linear drag to create ground friction, observe idling dynamics, and apply prefab changes for consistent behavior.
Create a sword hitbox in a top-down 2D Unity RPG, using a trigger box collider enabled only during the swing to detect hits and send on hit messages to slime.
Learn to implement damage handling in a top-down 2D Unity RPG by using public health variable with a backing property, destroying the slime when health reaches zero after three hits.
Learn to flip the sword hitbox with the player's facing direction using local position offsets and a directional callback, enabling precise hits and slime knockback.
Calculate the knockback direction by comparing the player, sword hitbox, and slime positions in a 2D Unity game, normalize the direction, and apply a defined knockback force.
Calibrate knockback force and direction in Unity by tweaking mass and linear drag, using collider positions to control force direction. Implement a targetable flag to disable collider after death.
Adjust the slime's sprite color across frames in the animation window to create a red tint on hit, then test with play and link to the death animation.
Recalculate the sword’s knockback direction from the player’s transform and adjusted pivot. Use the parent transform to compute knockback and apply force; disable the slime collider after hits.
Create a reusable health manager component that handles damage, health, and knock back for any character. Apply it to both slime and player and enable consistent death transitions.
Disable movement on defeat by toggling targetable and rb.simulated, apply to the prefab, and differentiate behavior for the player and slimes when entering a death state.
I've been experimenting and I find one way is to increase the linear drag on the rigidbody set in Dynamic mode. Instead of the Lerp to 0 (removing those lines entirely), you can set the rb.drag to a higher amount to get it to stop faster (Stop drag vs moving drag as 2 different variables for different character states). This lets the knockback apply more correctly. So for movement...
// Move animation and add velocity
// Accelerate the player while run direction is pressed (limited by rigidbody linear drag)
rb.AddForce(moveInput * moveSpeed * Time.fixedDeltaTime, ForceMode2D.Force);
And in the scripts where you apply force to the player
// Apply force to the slime
// Impulse for instantaneous forces
rb.AddForce(knockback, ForceMode2D.Impulse);
Letting the linear drag handle the knockback lets the rigidbody physics smooth out the velocity between the normal run and the knockback impulse.
Learn to move a 2d top-down character in Unity by applying forces instead of setting velocity, and tune knockback, linear drag, angular drag, and speed for responsive combat with slime.
Detect the player with a slime trigger zone, track valid targets by tag, and move toward them using a Rigidbody and a directional vector in Unity 2022.
Fade the text by adjusting its alpha from the starting color as time elapsed approaches time to live, updating every frame with the text mesh color assigned in the inspector.
Instantiate a health text prefab and attach it to the canvas with Text Mesh Pro. Place it above hit character using world-to-screen coordinates and gate movement via targetable property.
See the end result of a crash course on building a top-down 2D action RPG in Unity 2022, featuring enemy AI, knockback, player health, sword combat, and floating damage numbers.
Learn the basics on how to build a Top Down 2D Action RPG (think classic Zelda games) inside of Unity 2022. The main focuses of this course is on creating a working player with a sword attack, a slime enemy to chase and damage the player, and building a level to play on with pixel art tilesets including wall collisions. Another key focus is demonstrating the differences between kinematic physics and unity dynamic rigidbody physics with two versions of the player controller script so you can choose which method works best for you and your own games. Also important is the cinemachine package for creating a follow camera to track your player but maintain pixel perfect settings in Unity to avoid any screen tears or distortions.
In this course, we'll cover much of the core gameplay essentials games in this genre will need in their main gameplay cycle
Player Movement and Attacks with new InputSystem package
Building Tilemaps from Tilesets
Movement with Kinematic and Dynamic Rigidbodies
Making a Slime Enemy which can chase player, cause damage, and be slain
Setting up animations and transitions with Unity animation state machines
Creating hitboxes for directional attacks
Floating Damage Text numbers
Everything is written in C#, the standard language for unity games. You don't have to be a programming master. If you get stuck, feel free to download the finished scripts included in this course so you can get up and running.