Unity Game
Concept
Unity is a platform to create 3d games. The focus of this is on both 2d and 3d games, and it results in the creation of interactive content. It is an integrated platform that helps to build a game engine, and a framework is used to develop video games and stimulation for Computers, websites, and mobile devices.
The game is built in Unity3D by using the C# language for the scripting. The name of the game is CUBIX, in which there are three levels. It is a simulation of the cube in which obstacles are there in each level, and the timer is on to calculate the time. This is a game based on completion of degree crossing all the obstacles coming in between.
The game has 3 levels; the first level difficulty level is less. The Player has to finish all the standards, and difficulty is increased level by level. If player losses, then it again starts from the starting point of that particular level. It repeats in a loop until the player completes that level. Cube is continuously moving in the forward direction. The player has to use the keys for the movement in the left or right direction. There is a way given in that area; the only player has to move. A cube can fall from the way.
Simulation:
To give realistic effects, gravity has been used. If the player goes outside from the track, then it falls and loses the level. The collision of the obstacles with the player also gives a realistic effect.
Game :
The game is all about winning the levels by crossing the obstacles coming on the way, which is recorded by time. It is a Third Person Shooter (TPS) game in which the player is a cube. The Player has all the controls and the properties which a hub has. A player can see itself on the track, which is moving in the forward direction.
Visualization :
The game has the first frame as text, which asks the player to start the game. When the game begins, time is calculated, Player is viewed as a cube, obstacles are present in the form of cuboid and cylinders, the white track is there where all the barriers and player placed.background-color is green, which is giving a green look. After completion of every level message is displayed “level completed”. In last, after completion of all the levels, “Thanks window is displayed “with a quit button.
Target Audience:
The game is for people who are ready to accept challenges. The most played between the age group 14-23. The people who have high concentration power will be able to play this game.
Concept Visuals
Here are some screenshots of the game showing different level and behavior of the player while playing the game.
When we start the game, the first frame game is the staring window with a welcome message.
After clicking on button start, the game starts with the first level:
In this level, the blue cube is a player, the red boxes are obstacles, and in the middle, there is a number showing the time of the player. In white, there is a track for the player where he has to run. Outside, the track player gets out.
The Screenshot shows the message after the completion of level 1 “Level 1 completed”
In this image, if the player gets off track, then it loses, and again the level 1 starts from the starting.
This image player is in level 2, where the player collides with the obstacle, which is in red. The game has stopped here. It will again start from the level 2 starting point.
In this image, the player is in level 3, where the difficulty level is increased by increasing the obstacles. This is the starting point of the level 3 where the player has completed 12 sec.
This image player has collided with one of the obstacles in time 54 secs. Again it starts with starting of level 3.
Finally, the player has completed level 3 without colliding with any of the obstacles. The message has shown “Level Completed.”
After completing all the level 1,2,3, the player wins the game. The below message is displayed after the completion of all the levels successfully. There is a Button to Quit from the competition.
Requirements
Program Behavior requirements:
The programming requirements of the game are mentioned below:
- The location is required for the player.
- The direction of the player where to move.
- Movement of the Player
- Obstacles through which player will collide
- Initially, the player will assign it to the first level.
- Initially, the difficulty level is low, but it should increase the level by level.
- If the player collides with any of the obstacles, then the game should stop.
- A timer to record the time how much the player has run.
- If the player loses, then again, it should start with the starting point of that particular level where he has lost.
- After winning all the levels, Quit the game.
Assets Requirments :
- Player and obstacles need a rigid body which reacts to gravity.
- Mesh collider for collisions.
- Materials for the changing colors
- Animation after each level is completed
Analysis and Design
The game requires two types of components functional and non-functional which include:
Functional components are:
- Player
- Timer
- Player movement
- Collision
- Menus
Non – functional :
- Performance requirement
- Safety requirement
- Security requirement
The architecture of the game plan is :
Use – Case Diagram
Player
The player can start the game, pause the game, end game, and can win the game. The win is only achievable when the player crosses all the obstacles of three levels, and then it comes in the winning state.
Data Flow Diagram :
Yes
No
Yes
No
Next level exists
No
Implementation
Object | Component | My Activity | Comments |
Cube (Player) | Transform | Set position | |
Mesh Filter | Cube | ||
Box collider | Added | ||
Rigid Body | Added, set gravity | ||
Material | Added blue color | ||
Player Movement (Script) | Wrote | I adapted this form unity3D, Applies force in the forward direction, side directions but not in z-direction .https://www.youtube.com/watch?v=Au8oX5pu5u4 | |
Player Collision (Script) | Wrote | Adapted this form unity3d. It ends the game if the player collides. https://www.youtube.com/watch?v=WFkbqdo2OI4 | |
Ground | Transform | Set position | |
Mesh filter | Cube | ||
Mesh renderer | Added | ||
Box collider | Added | ||
Material | Slippery with color white | ||
Obstacle(Multiple copies) | Transform | Set position | |
Mesh Filter | Cube and cylinder | ||
Mesh renderer | Added | ||
Box collider | Added | ||
Rigid Body | With mass, gravity, and drag | ||
Material | With red color | ||
Tag | Used tag Obstacle | ||
Game Manager | Game Managers (Script) | Wrote | It involves the end of the game, Complete level, Restart of the game. Adapted from unity3D. |
Canvas (Panel) | text | Score | |
Panel | Level complete (script)which has text | Loads next level | |
Animation | Text | ||
End | Box collider | Added | |
End trigger (Script) | Wrote | Has inbuild function OntriggerEnter() https://www.youtube.com/watch?v=WFkbqdo2OI4 | |
Game Manager | Moved | As an object | |
Directional Light | Transform | Rotated to a good position |
By analyzing and designing the concept of the game, we have implemented a Cubix game that has three levels, and to win the game player has to cross all the obstacles. Firstly to carry out the game, we set the position of the ground, then the movement of the player by a and d keys. The player cannot move in the z-direction. Continuous force is applied to the player in the forward direction. Obstacles have the collision property so that if the player collides with any of the obstacle game stops and starts again. In the end, if the player completes all the levels, it comes in a winning state.
In the game position of the camera plays an important role, as if the player is the first person or third person. In the game, the player is the third person, so we managed to set the position of the camera in the right direction. The collision between the player and the obstacle was challenging to manage because whenever player strikes, the game should pause, and after a delay of 2sec, it should again restart with timing as zero. The ground should be resistant free so that players can quickly move. We managed it by adding the property of slippery. Animation of the level completed was also a bit difficult to manage the time.
We have successfully able to control the player by a and d keys. Delay in between the losing position and again starting from the initial position was also done successfully. Beginning of the timer just after the player starts playing and after completion of all the levels. Thank you! A message with a quit button was done successfully. We are unable to record the time and display at the time of losing the state of the player. Unable to provide the player his best attempt of all in minimum time duration. We are not successful in the movement of the player by arrow keys.
Firstly, when starting with unity, it was all new for us. Problems we faced during the implementation of the game:
- The focus of the camera how to set the camera and in which view it should be held so that it is easier for us to focus on the player
- Movement of the player, as the player is restricted to the track which is shown in white, outside of the track, he comes in losing state.
- Use of trigger property, to end the game and again start from the initial position.
- Use of Prefabs to increase the number the levels.
- Writing the scripts in C# was a difficult task to perform, as to record the action of the player, arrange the timing, and display the messages after each level.
The learning from the game involves – Use of in-built functions like OntriggerEnter (), Focus of the camera using different views – top, front, and side. Manage the movement of the player through the keys, create different game objects, Reference of one object in another game object, Animation of the frames which depends on the timing, writing scripts in C# by viewing or reading about different functions. How to process all the tasks and implement them by solving all the errors was a challenging task to do, but by learning all the methods and functions step by step, we can apply in the game.
Personal Statement
All the work and process did in the analysis and design done by my team only. For the implementation of the code and operation, we took help from the Untiy3d videos, as clearly mentioned in the implementation table. Movement of the player, collision to the obstacles have taken support for the process and better understanding as we are new to this language and there are a lot of inbuilt functions, so we have taken advice from the link https://www.tutorialspoint.com/unity/index.htm
How to script in C# for the beginning or start of the project, we took advice from https://unity3d.com/learning-c-sharp-in-unity-for-beginners to gain some knowledge about the functions and variables and classes to be involved in the game.
Personally want to thank all the teachers and online guidance for their help to carry out this work as the game is an example of the knowledge and ideas we implemented to build this game in Unity successfully.
For the functions, how they work have taken help from https://learn.unity.com/tutorial/coding-in-unity-for-the-absolute-beginner?signup=true#5cf19e6dedbc2a38d6e996c2