Monday, June 28, 2021

Unity Project: Marshie Re-treat

Marshie Retreat

This is an endless runner game made in Unity, featuring an original character, 2019.   You can find the Unity project by clicking the Github icon. ->GitHub

Concept


Main character sketch

Baby Boo just loves candy, but what parent would allow their child to have so much candy? In this game, Baby Boo is sent to another land – a Candy land – where he can collect all the candy he wants. Some candies, his favourites, give him special abilities to collect even more candy. But he must avoid some or else he will be transported back.


 Game screen visual




Requirements


Character requirements

The character, Baby Boo, will be moving forward (in the z-axis). Using the left and right arrow keys, Baby can move left and right respectively, allowing for movement in three lanes out of five lanes. The outer two lanes are boundary lanes.

He is given three lives initially and every time he collides with an obstacle, the player loses a life and respawns at the starting point, or the point of the last collected checkpoint.

The obstacles he comes across with are:

Choco Pool: These are part of the blocks and act as a puddle. They will have an empty collision box in front of them to catch collisions.
Choco Bar: A bar that blocks the way for about 3 units.
Rock: A candied rock that will sit on the path in any lane.
Bridge: For some of the path, it will narrow down to the middle lane and there will be empty game objects with box colliders on either side, to catch collisions.

The power ups he comes across with are:

Glow Candy: A very rare object to come across with. It will give the player another life.
Sugar Cube: Collecting the sugar cube rushes the player forward to the next checkpoint.
Gum Ball: Gives the player immunity from any collisions with obstacles.

The other objects he comes across with are:

Coins: Chocolate gold coins that should be collected to gain a score
Checkpoints: Flags placed every x units from the starting point.

The total score is calculated based on a few things:
The distance (number of units) covered by the player
The number of coins collected
Lives: a bonus for completing the course without losing lives
Number of powerups and checkpoints collected
Time?

(Almost) All objects will be instantiated randomly as the game progresses. Unwanted objects, or objects that have passed behind the camera will be deleted, as the player moves forward. Once the player has moved back, a new path will be constructed.



Asset Requirements


Character
Baby Boo: Character needs to be composed using a 3D modelling software. It needs various textures for the face (2d drawing), the body (2d drawing) and the limbs. It needs a RigidBody component, to use velocity and move forward, and a BoxCollider component to collide with other objects in the game. 

Game Objects
Pathway: The path needs to be made in a 3D modelling software as a prefab, so it can be instantiated multiple times according to necessity. A single row must have five blocks (or four, depending on whether the block has a chocolate pool, which must be a different prefab). The outer two lanes must have poles or lollipops which must be made up of a cylinder and a thinned sphere.

Power-ups and Obstacles
All objects must be made in a 3D modelling software as a prefab, so it can be instantiated multiple times according to necessity. All objects of this category will need a Collider component to allow the character to collide with the objects.

Gum Ball: A basic sphere will be used with a 2d texture. It will also use a particle system defined in Unity.

Glow Candy: A candy shape with a transparent green colour. It will have a point light on the inside to let it glow.

Sugar Cube: A basic cube with a 2d texture (like glass or sugar).

Rock: A rock mesh with a 2d texture.

Choco Pool: An empty block with a little animation to fit in with the path.

Choco Bar: A long rectangular shape with a 2d texture.

Coin: A cylindrical shape with a 2d texture.

Checkpoint: A flag-like object with 2d textures.

Scene
Canvas elements for the start and end of the game, as well as the game stats panel need to be done in Unity. The Start scene should comprise of ‘Start’, ‘How To Play’ and ‘High Scores’. The game stats panel should include number of coins, time elapsed, number of checkpoints, score and additionally, the power up in use, if any.


Design


The game consists of various scripts and actions. The most important scripts are moveCharacter, creatorScript and gameManagerScript.

The moveCharacter script contains all the character interactions, like movement and collision. The character will use the Rigidbody component and velocity to move forward in the z axis. A walking or running animation will be created for the character to move out of its stiffness.

On the character collision, there will be various actions accordingly. If the character collides with an obstacle, the lives variable in the gameManagerScript script will be reduced by one. If all lives are exhausted, a closing animation (particle system) will start before moving on to the end game stats. If the character collides with a power-up, i.e., a special candy, they will gain some sort of special ability or gain extra score, or both. If a collision happens with a collectible, like a coin or a checkpoint, the respective total, from the gameManagerScript script, will be incremented.

The gameManagerScript oversees the management of the base of the game. It allows the path to be created initially, at random, choosing between the various block prefabs. It also updates the status of the game (‘fail’ or ‘success’) and manages the lives and collectible variables. It keeps track of the playing time and the score.

The creatorScript looks at creating the objects (obstacles and power ups) on the path, at random. This is also done at random. It also interacts with the bridge triggers which should stop the obstacles from being created on the bridge (creating an impossible path).


Main activity flow diagram


Activity flow diagram: Start Game


Activity flow diagram: Play Game


Activity flow diagram: Moving forward


Development


Game screen visuals


I’ve managed to create the basis of an endless runner game. Using C# scripts to move the character and camera, along with canvas and GUI elements, this game has been designed to a basic level and can be improved upon given the time. The scripts use various features, like co-routines.

GUI: Player stats

The are several canvas elements also implemented throughout the game. The application opens with the StartScene which contains three different canvases. On button click, they switch between canvases respectively. On Play Game, the game starts off with a countdown. The high scores are stored using PlayerPrefs.

The LevelEnd scene brings up a summary of the game and the final score of the player. The player then has the choice to restart the game or quit.


Evaluation


Successful Implementation

  • -        Game design
  • -        Canvas elements
  • -        Scene management
  • -        Player controls (using C# scripts and components)
  • -        High score storage using PlayerPrefs
  • -        Unity animation
  • -        Sculpting in Unity
  • -        Material, Texture and Lighting
  • -        Particle systems
  • -        Instantiation of prefabs (choreographed and at random)

I had an issue with the player respawning at a given point. After the z-axis point manipulation was fixed, the lane kept changing after it collided with a power up. But I soon realized that the laneNumber wasn’t being reset to 0. The same issue arose with the restart. After reloading the scene, nothing was appearing except for the character. But that was also fixed by resetting all the variables that go along when the game begins.

On the SugarCube collision, the character moves ahead, but the Creator didn’t. All the objects were being destroyed and the Creator was supposed to spawn ten units ahead of the player.

There are still a few bugs in the game, like recognizing the bridge. In some situations, the Creator still creates random obstacles on the bridge, which isn’t ideal for play. One more issue is the randomly appearing ChocoPools in the path after the bridge, which still puzzles me.

The final game in Unity

Given the time for this project, there’s a lot that could’ve been done. One could be to improve on the graphics. An idea of progress through the game can be included, like various levels. Some difficult. Maybe and idea for special levels where you go through a dark course where you can only see a little ahead of you. Sound effects and audio could also be implemented for added bells and whistles.

0 comments:

Post a Comment




 
Loading...