The Orc and Wolf

Mobile Android Game

APK - Google Drive


1. Introduction


The game is about killing the enemies who are running to your character and try to kill you as well. As long as improving your character with the coins that drop from enemies from the store, scoring higher scores and the faster playable game will be possible.


This mobile game is implemented in the Android operating system and also tested in the Windows operating system.


There are Nav mash agents implemented to enemies, which will make them follow and attack the player with specified animations and controllers. There is also a script for the player which will detect the enemies’ interactions with the player and will create reactions based on it. Also, implementation of other game objects with rigidbody attributes and their scripts have been made. For last, some scripts for stats of the player and the enemies have been created.


2. The Goal of the Game


The goal is to survive from the enemies as much as possible and try to have a high score by killing them. There is 4 type of enemies which are orange, green, red and blue colored. With the given order, the orange-colored enemy is the weakest one with 50 HP and five damage, blue-colored one is the strongest with 200 HP and 20 damage. Also, these enemies get stronger with 5 HP and one damage increase when the player has killed each one. To survive in the late game, the player should save some potions on its inventory, which can be obtained from boxes that blue enemy drops or be prepared with increased armor and HP and try to avoid stronger enemy types. As long as the character drops to 0 HP, the game will be finished and the player will return to the main menu.


3. Techniques and Algorithms


The game consists of two screens. One is for the menu and the other is the playable game screen. Menu screen contains three specific menu children in canvas, which are the main menu, store menu and tutorial menu. Menu buttons have click listeners for such as menu swapping, changing specified player preferences keys and starting the playable game. The tutorial menu is a one-time menu, which will be showed if the player is a new one.


The game screen contains essential objects such as Orc_Wolfrider, which is the character of the player, the terrain, the objects of the terrain, the spawner for spawning the enemies and the game manager for getting the required instance variables when the game is played.


Orc_Wolfrider has a rigidbody and a character controller for physics and easily control. It also has required scripts for character controller usage with a joystick and for understanding the button presses based on the type of button. It also has an inventory to track collected coins and boxes with the projection of these numbers on canvas. This game object should have physic attributes such as speed, gravity, HP, damage and armor information and also attaching the health bar and armor bar to these stats. Also, the character has a throwable axe attachment on this object, which will spawn a spinning axe at in front of the player and this axe will move on the character’s direction which will hit 25 damage to the collided enemy.


There are also EventSystem and Spawner, which are not visible game objects, yet each has specific tasks. EventSystem is for understanding input from the game, which is joystick buttons. Spawner is for spawning the enemies in random locations, restricted with map’s borders. It has a script to specify border locations of spawn points, average wait time for spawning and list of enemies with the selected game object prefabs.


Enemy prefabs from Heavy Knight PBR have rigidbody, Nav Mesh Agent, character controller and scripts to control their HP, damage and intelligence. When they spawned at a random location with spawner, the target of these enemies will be assigned to themselves. They will check the distance between this target and make some different actions depending on it. Between the character and enemies, there is no collision detection. It is about detecting the distance between them and detecting the enemy’s or the character’s current move. For instance, if the character’s animation is set to attack animation when there is no distance between these objects, the enemy will take the damage and make the required actions depending on it.


The terrain has been created with Terrain Tools of Unity for better user control to design it. A solid rock texture has been chosen from this package and borders of the map have been made with mountains.


The object prefabs for this terrain has been gathered from LowPoly Environment Pack. These objects are set to have mesh colliders with their model meshes. The character will collide with them, but the enemies will not. The reason is to get rid of bugs such as object can stuck to these objects and the player may use this vulnerability of the game for benefits.


In the store menu, the player can increase its character’s hp by ten or starting armor by 1 or armor capacity by 1 with 50 coins for each. For extra, the player can also open the boxes dropped from this menu.


In addition, there are 2 types of potions and boxes in the game, which have %50 drop rate from each enemy. Their prefabs are used from RPG Pack. Red potions set the character’s current health to maximum health. Green potions give one armor, which cannot exceed maximum armor capacity. The boxes can drop from the blue enemies. These boxes have a chance to drop 1-7 throwable axes, five coins, or one red potion.


4. Scripts


The main game objects are the enemy objects and the character object. The character object has PlayerScript.cs and PlayerStats.cs for the main features. PlayerScript is about moving the character and getting input from the joy buttons. Movement() function separated regarding isPC Boolean for testing purposes. Joystick class returns a float depending on its rotation between -1 and 1. If it is 0, the character stays idle. If it is not, it runs the running animation and moves with specified physics variables. The character cannot move if it is attacking. GetInput() function checks if the character is on a stable location and decides which button is pressed. If joybutton class is pressed, it runs Attacking() function and stops running. Attacking() function starts a coroutine, which sets attacking animation where this condition variable helps the enemy to detect if it is attacked. potionButton class checks if the character has enough red potion and if it is, it sets up the current health to maximum health. throwButton class also follows the same procedure for checking availability from PlayerPrefs and runs throwButton() function, which gets the last location of the character and instantiates the throwable axe with an offset of 1.


PlayerStats.cs and BlueStats.cs classes are similar. Both of them hold damage and armor with the Stat.cs class. PlayerStats initiates the character’s stats and returns the function depending on taking damage, increasing armor, or dying. The difference between these stats classes are the hitDamage() function on BlueStats.cs and DieAnimation() function on it as well. hitDamage() function detects the enemy’s attacking animation and decreases the character’s HP based on the enemy’s current damage. DieAnimation() triggers when an enemy dies and sets up item drop and makes next spawning enemies stronger.


BlueController.cs is the enemy’s controller script. Each enemy has a different detection radius for the target. Depending on this value, the enemy’s condition changes. To trigger this value, there is a distance variable which determines the distance between the enemy and the character. If the enemy is dead, the enemy’s destination becomes itself to stop them moving. If the distance is more than lookRadius, it stays on idle. If it is not, it will be on running state and destination will be the target. Retargeted Boolean is to detect if an enemy enters to lookRadius and leaves it and re-enters to there again. If the enemy gets near the target, FaceTarget() function triggers, which changes the direction and rotation of the enemy. Attack() function starts a coroutine and deals damage to the character in every 3 seconds. To stop confusion between attacks, there are attack and attacked Booleans to check these cooldowns. If the character’s animation is attacking, GetHitRoutine() starts and TakeDamage() function triggers. GetHitRoutine() casts getting hit animation for 1 second.


Each item has a specific integer number for classification. Each prefabs of these items have this class with sphere collider. On trigger, itemPickUp() function starts and depending on the item number, it makes its task and gets destroyed.


throwableAxe class is attached to axe prefab from Axe package. It gets triggered based on collision enter with the enemy objects. It deals specified damage to collided enemy and makes enemy’s lookRadius to 100f for taunting the enemy. After that, it gets destroyed. If it does not hit an enemy after 4 seconds or goes out of the map, it gets destroyed automatically.


References