Remaking Mario in Unreal Engine 5 (Part 4)
(This post follows on from this page: https://triplehitcombo.blogspot.com/2024/07/remaking-mario-in-unreal-engine-5-part-3.html)
Last and by no means least, we hit the final page and it's all about the blocks! Okay, a little bit about the Third Person Character as well.
Let's get that bit out of the way first!
In the construction script, we set a function for when the player dies. A sound plays, inputs are disabled, an emitter is spawned, character movement is disabled and an animation plays to jump the character up slightly, in Mario fashion.
In the event graph, we have the death function. It plays out as the construction graph would indicate, with the player dying and the transform location updating as I intended.
Once the location is determined, a delay is set and a cast to the player is made to deduct a life from the player, then the player actor is destroyed.
In the Modify Hit Points section a few checks are needed. First off, I needed to check what hit points we had, whether we are equal to zero, above zero etc. A sequence node was then added. First it changed the colour of the mesh depending on damage level. I clamped the integer between 0-2 (For 3 stages of health; death, small, large) and if the integer was zero, then player death was called. If it was false we set the material colour using a select node that went through a couple of different options based on the integer.
Blocks!
Okay, we have made it to the final section of the Remaking Mario posts and it'll be the biggest one so strap in!
For starters, I made a parent block, this housed a majority of the scripts and variables needed, a lot could be reused depending on what block I am making
For the breakable block, we cast to the player and check to see the size of the player, if it is too small, the block won't break.
If the player is the right size, a sound is played on hit, some points are added and the block is destroyed.
The coin box is a classic Mario staple. This block is hit multiple times and yields coins every time it is hit and then stops giving coins are an allotted time. The first thing to do was create a Bool check. This was to see whether the player is interacting with the block or not.
Now we set the timer for the block (instance editable), then play a sound effect and add points (instance editable)
Then we add coins (instance editable) and finally, play an animation of the block bouncing up and down as we hit it.
There is also a fake breakable block and this operates like the coin box. It doesn't require an interaction check or timer, but everything else remains the same! Next up is the "?" block and guess what? It's the same story, though this time we can set how many coins are inside (Or any item we desire).
For a trickier block, we have the invisible block. The player cannot see this block in gameplay and can only jump up and hit it to reveal the coin inside the block. If they hit the side or top of the block first, they pass through it. The bulk of the code is the same as above, but there are a couple of additions. First, is turning visibility on when the bottom of the box is hit.
And here we check exactly where the character is hitting for the code to respond accordingly.
(There was a P-Block function that was working really well but it had to be axed as it caused issues when trying to cook and package the game)
And for the final piece of the puzzle, the Fire Flower! We will give it its own section
Fire Flower
For the final section we will be hopping into a few different graphs!
First, we have to ensure that the player gets the power up and once they do the components on the block need to be destroyed and some points are awarded too.
In the Third Person Character event graph, we house the Fire Power event and when the player picks up the flower, a sound is played and an animation is played to grow the character to full size, when the player is damaged, they revert to their smaller size and lose the flower.
So, we have a flower and it make us get bigger and stronger, but we need more. Now we add fireballs!
First, I made this as a BP Actor and adjusted materials on a sphere and added fire effects to it.
I now set the logic for the fireball in the event graph. I set the max amount of fireballs allowed at once as two. I made a hit check to see if the fireball has hit anything and only allowed us to spawn more if at least one fireball had hit something and disappeared.
This restriction was created in the Third Person Character as well as its transform location and speed when it is thrown, a sound effect is also played when the fireball hits something.
As the Goomba is our main adversary, I wanted to make sure fireballs kill them. As promised, we go back to the Gooma event graph and add in the logic. I spawned the fireball as normal and destroyed it when it hit the Goomba. Then I added extra points to the player and then destroyed the Goomba.
And that wraps up the bulk of how I achieved the project. It's been over a week since I touched the project so i may be missing some things! Also try as I might but this project just won't cook or package despite no errors. I've tried command prompts, bat files and Powershell command and nothing! Nevermind, Nintendo would take it down in five minutes anyway.
Nevertheless, here is a video of the complete experience. It's only four very short levels, but I'm really happy with how it turned out.
Comments
Post a Comment