Mathing a Mario

For project 1 there was a few things that required me to delve into the world of programming, even if the ‘delve’ was the equivalent of dipping a toe into the ocean. I needed to program the player controller, the audio controller, the goomba controller, the coin function, mushrooms, and of course a menu controller. I had a pretty good idea how to do these scripts, thanks to my prior work in scripting.

To begin, I made the player controller (of course). I decided to make the player use a rigidbody so I could easily make it work with unity physics. So for the beginning of movement, I used simple add force to the rigidbody based on key inputs. The force variables were the tricky part to get set, and it took a while to balance to something that moved comfortably for the build. I also needed to make the ‘boost jump’ function as part of this because if I want to recreate Mario, I’m going to have to make him jump higher if you hold the jump button. This took more time than the rest of the player controller, simply because it was difficult to get the player to float up the right amount. I had some issues with the player’s ground check initially because I had the ground made out of many singular blocks. So I removed the ground check that would prevent jumping after exiting a block, and instead made the check turn off when the player jumps. This did allow the player to jump after walking off an edge, but that was ok since not many people noticed it during testing. After the player was moving well enough for a basic, botch build, I moved on to the goombas. The goombas also used a rigidbody, since they needed to be able to fall off of things as well as walk along the ground. The movement for the goombas was quite simple, just adding force to a rigidbody in a set direction. Getting the goomba to turn around was the tricky part. I started by placing a trigger collider on the front of the goomba and getting it to change the direction of the goomba when it hit anything that wasn’t the player. But then the goomba would just walk off the edge of the platforms and fall to his doom. I eventually made a second collision area beneath the level that would stop the goombas from falling off the map while allowing mario to. I know it would probably have been better to have a trigger collider that turned them around rather than a wall. After having made the goombas, I realised the mushrooms moved in a very similar way, so I took the goomba script and applied it to the mushroom item, and then made a different tag that would act differently when triggered by the player. With the mushroom item in, I needed to make the player act appropriately when using the mushroom. To do this, rather than making a new player version to replace the smaller mario, I just doubled the y scale of the payer and made a system for ‘lives’ to mimic the normal, big mario.

I then went on to add the coins after this, so that I could closer recreate the 1-1 level to the best of my ability. I used a trigger on the mase of the blocks that would spawn the coin item above the block. The coin item would then be a separate object that would play the coin sound, add one to the score then delete itself after a small amount of time. This function needed to account for the multi coin blocks within mario 1-1, so I made the function have a counter that would allow a certain amount of coins to be collected before it set the image to a new block. I took this coin function after this to create the basis for the block breaking function. This function would break the brick textured blocks. I did not get this to only function when the player was big sadly, so I probably could have done that. The Final thing I did was to make the win and lose states combined with the menu screen and lose screen. The flag did not function the way I intended, I originally hoped to make the player lerp down the flag to the ground. They instead teleported, stood still for a moment and then the game cut to the win screen. The menu was quite simple and was just some ui buttons that progressed to the game or quit.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s