GAMES DEVELOPMENT / FINAL DESIGN

 Hasnol Rafiq Bin Hasnol Raduan / 0356767

Games Development / Bachelor of Design (Hons) in Creative Media / Taylor's Design School



Final Task: 

I was tasked with creating a 2D platformer game using Unity. This journey has been both challenging and rewarding, as I have had the opportunity to explore various features of Unity and understand how they contribute to the development of an engaging and interactive game. In this blog post, I will detail my progress and explain how using Unity has been instrumental in bringing my game to life.

Figure 1 - Sprite Assets

 Sprites are essential for creating the visual elements of my game. Unity's Sprite Renderer component allows me to display and animate 2D images easily. By importing sprite sheets and setting up animations, I was able to bring my characters and environments to life.


Figure 2  - Scripts

Figure 3 - Game Structure

Unity's intuitive interface makes it accessible for beginners while offering advanced tools for experienced developers. The Scene and Game views allow me to design and test my levels in real-time, providing immediate feedback on any changes I make.

Unity's physics engine and collider components enable realistic interactions between game objects. By adding Box Colliders and RigidBody 2D components to my player and enemy sprites, I can simulate physical interactions such as collisions and gravity. This has been crucial for creating a believable and engaging platforming experience.

Tags and layers are essential for organizing and managing game objects. By assigning tags to my player, enemies, and interactable objects, I can easily reference and manipulate them through scripts. Layers allow me to control which objects interact with each other, optimizing the game's performance and ensuring that collisions and physics behave as expected.



Figure 4 - Game Structure (Close Up)

Creating prototypes and testing different gameplay mechanics has been essential for refining my game. Unity's Play Mode allows me to test my game in real-time, quickly identifying and addressing issues. Gathering feedback from peers and instructors has been invaluable. By iterating on my designs and incorporating suggestions, I have been able to improve the overall quality and playability of my game.


Figure 5 - Scripting

Scripting in C# is a core aspect of Unity development. By writing custom scripts, I can control the behavior of my game objects and implement game mechanics. For example, I created a PlayerController script to handle player movement, jumping, and interactions with the environment. Additionally, I developed a MobBehaviour script to manage enemy patrol and chase behaviors.

The player movement script is responsible for handling the player's input and translating it into character movement. This involves detecting key presses for moving left, right, and jumping, as well as ensuring smooth and responsive movement. The script captures input from the player, such as pressing the arrow keys. It then translates this input into horizontal and vertical movement. For horizontal movement, this typically involves applying a force or directly changing the player's position. For jumping, the script checks if the player is grounded (i.e., in contact with the ground) before applying an upward force. The script also communicates with the Animator component to trigger appropriate animations based on the player's actions (e.g., running, jumping).

The mob behavior script controls the actions of enemy characters, making them patrol a certain area and chase the player if they come within a certain detection range. The script defines patrol points and moves the enemy between these points using a simple AI. When the player enters the detection range, the script switches the enemy's behavior from patrolling to chasing. The enemy will then follow the player until they exit the detection range. If the enemy gets close enough to the player, it will trigger an attack animation and potentially reduce the player's health.

The player health script manages the player's health, reducing it when the player takes damage and triggering appropriate responses when health is low or depleted. The script maintains a variable for the player's health and maximum health. When the player collides with an enemy or a hazardous object, the script reduces the health variable. The script updates the health bar UI to reflect the current health status. If the health reaches zero, the script handles the player's death, which could involve playing a death animation, restarting the level, or ending the game.

The player attack script allows the player to perform attacks, dealing damage to enemies within range.
The script detects when the player presses the attack button.
It triggers the appropriate attack animation.
The script checks for enemies within the attack range and reduces their health accordingly.
To prevent spamming attacks, the script can implement a cooldown period between attacks.

The health and healing script allows the player to restore health through various means, such as picking up health items or standing in healing zones.
When the player collides with a health pickup, the script increases the player's health up to the maximum limit.
If the player stands in a healing zone, the script gradually restores health over time.
Similar to the player health script, it updates the health bar to reflect the restored health.

Scripting in Unity provides the flexibility and control needed to create complex game mechanics and behaviors. By breaking down each aspect—player movement, mob behavior, player health, attacking, and healing—I was able to create a cohesive and engaging gameplay experience in my 2D platformer game. Understanding and effectively using these scripts have been crucial in developing a game that is both fun and challenging for players.


Figure 6 - Animator

The Animator component in Unity is a powerful tool for creating complex animations. By setting up an Animator Controller, I can define different animation states and transitions for my characters. This has been particularly useful for animating my player and enemy characters, making their movements smooth and responsive.

Figure 7 - Main Camera

Unity's camera system is flexible and highly customizable. By using a Camera component, I can control the player's view and create dynamic camera movements that enhance the gameplay experience. Adding a Cinemachine component has allowed me to implement smooth, automated camera transitions and follow the player seamlessly as they navigate the game world.


Comments

Popular Posts