Concept and Set up Stage
Our fourth and final required assignment was to create a prototype of a platformer game akin to the likes of Super Mario franchise. At first I was intrigued by this opportunity to design my own explorable environment rather than being contained within a strict “arena” like my previous two environments.
I found an old piece of concept art I had created for a different module on my course to be a fitting stimulus, and thus I based my work around this piece:

This would once again be a 2D core project Built in Version of 2022.1.7f1 however this time upon creating the project, I would have to insert 3 additional windows into my scene: The Animation window ,used to create animations out of sprites, The Animator window, used for linking said animations, And finally the Tile Palette window, which i would use to create the platforms for my level.
Aside from that I would also be creating folders to store my script, sprites and prefabs alongside animations and tile folders.
Design
I started by creating a series of Assets for this project. In all I needed a playable character, enemies/hazards, tiles as to create the platforms and decoration for the environment.







After creating a myriad of assets to be used within my game, I then needed to tweak them for different use and animations. I reused the main Bricks to be used as a background by changing their hue and editing them to look old and broken walls like from my stimulus


Following this I also edited my main character asset to have multiple frames of animation rather than appearing static like my previous projects. I had then grouped these frames together into one image and imported them into my sprite folder.

I then added these larger images within my scene in which unity then opened them up to be “sliced” this process automatically separated the different frames of the animation into an individual sprite, however I did need to clean these up by dragging the box tighter to the sprite as it wasn’t 100% accurate. Nevertheless, it then allowed me to save these image as animations.

Following this I could then drag these open these new animations in the Animation window.

In this window I could open the dope sheet which allowed me to alter the length of animations, add a delay between frames as well as add or remove frames. When importing my looking right idle animation, I found it to play too quickly therefore I added a 0.01 second delay between each frame which allowed the animation to play much smoother.

Implementation
After adding the finished edited sprite within my scene I created a new prefab for my player. I also created two new prefabs for both my cat paw enemy and the mouse trap.
However at current there was nothing to in my game therefore I started by beginning to create a new 2D object, a tile map. I added the tile map into my Hierarchy and named it ground. Whilst I opened the tile map, unity automatically made it a child to a parent grid object. This grid would be used to paint on the tiles into my scene.

Following this I opened the Tile palette window and created a new palette, and named it ground. I the dragged my two tiles I had designed earlier into the palette and saved them into a Tile folder, from here I was free to paint onto the grid after selecting a tile and using the paintbrush tool atop the window. whilst creating my level design I also used the eraser tool to delete tiles and the paint bucket tool to fill in a larger area of tiles.
After setting up my Tile palette I then needed to add in some important components to my Tile map object. I added the Tile map renderer, so the palette would show. the Tile map collider and Composite collider 2D which were used together to create collision for the tiles, i connected these components by checking a box within the Tile map Collider “Used by composite” which made the collision within my scene a lot smoother.
Finally I added a Rigidbody 2D to add physics to the Tile map. I changed the body type to static as these objects will not be moving within my scene

After I had painted a rudimentary level layout I then needed to test it with my playable character. However before I could get my character moving I first had to open the animator to add transitions between the different animations.

Once I had dragged all my animations into the Animator window I use the right click to begin making links between the differing animations so my character could transition between their walking jumping and idle animations fluidly. when creating a link between different states, i had to add conditions for when they could play like so:

Following this I began work on my movement script for my player prefab so I could move around the level freely.

Once again I added a public float variable to influence my speed (making sure it was public so I could tweak that value in the inspector rather than hard coding it into my movement. This code works by fetching two components I had added to my player prefab previously, those being Rigidbody2D alongside the Animator component which was added whilst I created my transitions between animations. (I had also added a Box Collider however that wouldn’t be used until later on).
After it had called these components when the game began to run, I then used a fixed update so that it checks similarly to a regular update however isn’t effected by a higher framerate which could cause some issues later on such as animations playing too fast or incorrectly. The Fixed update then Uses a Vector2 to increase the velocity on the rigid body, along the X axis when the player uses a “Horizontal” input.
These include the Left and Right arrow keys and the AD keys and are found within the project setting input manager.
The last bit of code checks if your movement is <, > or = to 0 which essentially means if you are heading left right or not moving respectively it then sets walk state to the appropriate number linking the conditions between the animator and the script.
When I wanted to add different idle animations depending on the way the character was facing I realised I could only create certain links between different states, for example while I could be facing right I wouldn’t put a link to the facing left idle only between its facing right idle and vice versa. This meant I didn’t have to include another condition within my animator as both my idles could be set to 0 as it would still work alongside the script
I attached the movement script to my player prefab before starting a new jump script. just before that however I had to add a new empty child object (Called GroundCheck) onto my Player prefab, this would house a capsule collider on my sprites feet. Alongside some Tags for my player prefab (Player), Cat paw (Enemy) and Ground tile (Ground) all of which will be important for later scripts.


This scripts starts by declaring many variables such as the Animator, which is used to change the walkstate again whilst the character is in the air and Rigidbody variables again to be used similarly to what was done in the previous script. however Some Bool variables (True or false) need to be included so that my character cannot move feely along the Y axis, as while the physic used in the Rigidbody component will make me fall back down, I could repeatedly press the space key (as is declared in line 35) to continue making my character jump upwards, defeating the purpose of my entire game. therefore when declaring the if statement in line35 another requirement is added !isJumping (which means isJumping is set to false)
isGrounded checks if we are touching the ground due to the collider component of the Groundcheck object. If that object is toughing anything tagged as ground the Bool is set to true due to it being a child of the player. isJumping asks if the player is in there air which is known if isGrounded is false. Therefore is both is true, only isGrounded can be true otherwise the script will restrict the player from jumping.
there is also a public integer that would allow me to set the total number of jumps however this goes unused within my final game as I didn’t want to feature a double jump.

Following this I then began the kill script which would destroy the player object if it came into contact with the mousetrap or catspaw. first however I needed to add a Rigid body and Box Collider 2D to both to ensure they had collision and physics.

This is the full script I attached to my hazards, this checks if what collided with it was tagged as a player, if so said object is destroyed.
I would later reuse this script for my end goal
However I wanted to be able to kill the catspaw and bounce off it like you do when jumping on the heads of enemies in other platformers, therefore i reopened the groundcheck object and wrote a new script:

Similarly to scrDeath, this checks if the object Groundcheck has collided with is tagged enemy, (which the catspaw is) if so it destroys the object and allows the player to bounce upward using a Vector2. this is a public float so the value of this can be changed within the inspector.
The reason this works is due to two reasons: Groundcheck isnt tagged as player so the two objects don’t destroy each other and the collider is only at the feet on the player sprite meaning it can only collide from above for this to take effect.
Now that all my objects were working correctly I needed to program the camera to follow my characters movements, whilst I technically could attach the camera to my player character. instead I decided to create a script for more consistent and smoother camera movement.

The public float variables allow me to determine the speed at which the camera follows my player object from the inspector. similarly to how my zombies functioned in my top down shooter prototype (Link here: https://baines-2022.hulldesign.co.uk/2022/11/25/prototype-3-trench-raiders/ ) I use Game object. Find (“Player”) which makes the object target the object called “Player” which in this case ins the controllable character.
The second portion of the code transforms the position of the camera to move towards its target. “.lerp” is used to create a linear path between two points that being the cameras current position and the players current position. The camera follows along this linear path at all times.
it is under an if statement, simply because it the character was “null” (gone from the scene) this could cause some issues in which the camera tries to find the object but cannot and could lead to a crash. This needed to be avoided as in this prototype the players object can be deleted.
Finishing Touches
With all aspects and mechanics working this allowed me to finalize the level design to make sure it was fun, challenging but also not unfair.
I made sure to create a safe obstacle at the start of the game to ensure the player was free to experiment with the feel of the jump mechanics before putting them in any real danger.

Following this I then added some assets to be used as decoration such as table legs for the tables and arms for the cat paws, alongside a backdrop i created to mirror that of my stimuli.
I also tried creating a series of particle effects to use as a starry nights sky in combination with a colour changed camera background, however I was unable to get this to work.

Much like my previous projects I also included implemented Fmod by replacing the unity listener with an Fmod equivelant.
I also added some Fmod emitters for sound effects on certain queues and also a short script to play a sound event each time I jumped

Conclusion
Whilst not the most challenging or the easiest I had done so far, this final project was extremely rewarding for me to complete. i feel with a little more time I could expand my ideas and create much nicer visuals for this game. It was also very fun experimenting with my animations.
However I am not 100% satisfied with the state this prototype is in. For example when you fall down a pit in my platformer nothing happens to you where instead I should’ve created a large empty2D object with a box collider with the scrDeath script attached to kill you. Furthermore I had an idea to add a score system like my previous prototypes. implementing a canvas to create a HUD for the player that displays their score.
I even created a cheese asset to work along side this:

Looking back upon all my prototypes, I realised I have learned a lot about the unity engine and things that would confuse me whilst coding in C# now make much more sense to me once I have put this into practise. looking back into how I found the simplest cookie clicker project is quite eye-opening for me and I look to expand my knowledge of unity in future projects to come.
The Project is playable here:
https://anonamigo.itch.io/ratrace

































































