Games Development Task 3: Game Prototype

11/6/2024 - 9/7/2024
Edwin Choo Quan Rong / 0348305 / Bachelor of Design (Hons) In Creative Media
DST 61104 / Games Development
Task 3


Task 3: Game Prototype


Player Character Setup



Fig 1.1 - Player Inspector

I setup Capsule Collider 2D and Rigidbody 2D to create realistic physics for the player character. Meanwhile, the Player script itself consists a bunch of public float functions to freely edit the details from the inspector itself.


Fig 1.2 - Collision code (Realistic Physics)

By creating empty game object in Unity and inputting it into the public Transform and float in the Inspector menu, I can utilize Gizmos to create a check for when the player is touching the ground, wall, and attack hitbox. This line can be adjusted freely by adjusting in the Inspector for quick and easy edits to the character's physics, which makes it easy to edit later on during the development process.


Fig 1.3 - Flip code

This Flip code here ensures the player character is facing in the direction the player is controlling them towards. The flip uses transform tool to edit the Y-axis of the character by 180, with "if & else" features calling the Flip function whenever players change the value of the X-axis input by the player.


Fig 1.4 - Movement and Dash code

The movement code draws from multiplying the X-axis input with the move speed of the player set in the Inspector to create player movement, while the dash multiples itself with the dash speed set in Instructor with the Y-axis ending in zero velocity to end the dash. The movement value is set to 8 while dash is set to 25, with the dash basically being a very quick movement called by the code.


Animations


Fig 1.5 - Sliced Character Spritesheet

With the character movement functions and attack hitboxes being set up, its time to slice the character spritesheet and input the character sprites into the Animator.


Fig 1.6 - Setting up Animation

The sprites are drag and dropped into the timeline as keynotes and evenly distributed by adjusting the sample rate below the play button. Once the animation looks smooth from adjusting those 2 factors, I proceeded with creating new animation clips and importing the other sprites into the animator.


Enemy Character Setup

Most of the features used here is the same with the player movement, physics, and animation setup above. However instead of using GetKey features to call the action from the player's perspective, they have their own logic for movement and attacking.


Fig 1.7 - Enemy Inspector



Fig 1.8 - Enemy movement logic

This function here triggers a boolean where if true, the enemy would stay static and wait for a few seconds before moving again. By calling this function, I can create enemy movement paths for them to stay static when hitting a wall, then change their direction towards the opposite direction, as well as using this to signify them transitioning out from aggro state to normal movement state.


Player Mechanics

Counterattack


Fig 1.9 - Counterattack Indicator


Fig 2.0 - Counter Image Inspector

As an additional feature, I want to create a parry mechanic for the player, to which it will be symbolized on the enemy during their attack window. Firstly, I assign a sprite renderer to an empty game object to symbolize the counter window on the Enemy game object.


Fig 2.1 - Counterattack Code

This is the counter attack code for the player to successfully counter attack the enemy. Firstly, Collider2D and Physics2D is assigned to setup the attack hitbox, where once enemy component is obtained and enemy can be stunned, the counterattack bool triggers and players can deal damage to the enemy.


Ranged attack


Fig 2.2 - Ranged Attack


Fig 2.3 - Ranged attack Inspector

I wanted the player to have a ranged attack to provide more options in the game's combat. Firstly, a prefab for the ranged projectile is assigned along with the prefab for the dots created using circle in an empty game object and adjusting its color and size. Then, I can adjust the amount of dots and space between them after setting the float details and dot generation code inside the script.


Wall Jump


Fig 2.4 - Wall Jump code

In certain parts of the level, the player will have to use a wall jumping mechanic to traverse towards the end of the level. This wall jump ability is coded by using multiple "if & else" statements to call previous functions of xInput and facing direction to bounce players towards and upwards the opposite direction from the wall they are currently facing.


Damage Function


Fig 2.5 - Damage function in code

By setting the values of damage via the Inspector, the code takes the assign values and trigger the DoDamage and TakeDamage function, where once the HP is reduced to 0, the player character will die. This code works on the enemy as well to deal damage and receive damage from the player.


Fig 2.6 - Damage Visual Effect code

Additionally, the damage function has a visual effect assigned to the player & enemy character. It uses a material created and assigned to the Inspector and triggers the material to appear and flash red and white when struck by an attack.


Tilemaps Setup


Fig 2.7 - Tilemaps Setup

The tilemaps were setup by creating a new palette and importing the tilemap assets into the workspace. To differentiate between the ground, background, and decorations, I assigned different active layers into the Hierarchy window and assigning the necessary sorting layers to symbolize the difference between the objects. Only the Ground tile layer has Tilemap Collider 2D, Rigidbody 2D, and Composite Collider 2D assigned to it to have the player collide with the object for movement.


Changing Levels (Scenes)


Fig 2.8 - Next Level Inspector

Firstly, I assigned a tag named "NextLevel" to the game object in the hierarchy. With the door going to the previous level named "PreviousLevel". A box collider 2D is then assigned to the game object so that when player triggers a collision with their player character, it will activate a code to load the next scene or load a previous scene.


Fig 2.9 - Loading level with SceneManager

With this code, once the player collides with a game object with the specific named tag, in this case being the door sprites used to proceed to next or previous level, it activates the SceneManager to load a previous or next scene according to the number hierarchy the scenes are arranged underneath Build Settings menu. By using GetActiveScene() function, the buildIndex being added or subtracted will always allign with the players progressing to the next level or returning from a previous level.



Current Development Progress


Fig 3.0 - Level 1 Layout (wip)

This is the current layout design for my game. There are still quite a number of tasks to do to polish up the game and create a smooth experience so I'll be listing down what has been done and what's to be done in the future.

Completed Tasks
  • Player & Enemy movement
  • Player collision
  • Player Jump
  • Player Dash
  • Player wall jump
  • Damage Effects
  • Damage Stats
  • Character Animations
  • Tilemap setup
  • Doors to proceed or return from each level

To-do Tasks
  • Player attack (more refinement)
  • Player ranged attack (more refinement)
  • Player counter attack (more refinement)
  • Creating tutorial stages for player 
  • Creating 2 more level designs (Level 2 & Boss stage)
  • Creating Main Menu and Game Over menu
  • Creating respawn mechanic and player respawn screen upon death
  • Creating HUD UI and health bar for both player and enemies
  • Adding BGM and SFX to the game


Reflection

Diving headfirst into game development was an arduous task as using Unity and learning the capabilities of the software for the first time was a lot to take in. I scoured the web for multiple tutorials to aid with what I was developing, luckily finding a few that aided with 2D platformer development. Due to the time needed to develop even simple mechanics as everything is being learned from scratch, I soon came to realize that my initial game idea of a Metroidvania inspired genre being too huge of a task to complete. Thus, I begin to simplify the contents of my proposal and find creative work-arounds to focus on developing a MVP at first before considering adding any additional features.

However, a change of plans brought me new insights into the development of the game. It helped me to better understand the base MVP version of my game to plan for mechanics I can implement in the future. It also helped me set realistic goals to ensure that the tasks to be completed can be done in a timely manner.

Overall, game developing as a first time experience was difficult but satisfying once the mechanics you plan to implement works when doing game testing. The experience I gained here does help me move forward in games development with a more realistic planning as well as the ability to be flexible and adapt to change in game developing process.

Comments

Popular posts from this blog

Collaborative Design Practice - Task 1: Empathy Map & Problem Statement

App Design II - Task 2: Interaction Design Planning & Prototyping