Devlog 3.2 - Player, Enemy, and Interactions


Devlog 3.2 - Player, Enemy, and Interactions

Devlog for the game 'Into the Mist', a game project/assignment for KIT109.  

Player Movement Update

The player follows a grid-like movement, as we discussed in devlog one. We decided to update it since we encountered a bug; since we were using raycasting, there were times when the user could click on tiles, and it prompted the highlighted tile to appear (which is not good). We decided to use a button fitted to the character player mode (Figure. 1); this way, users are less likely to miss a click or encounter some unwanted bugs in moving the player. 

Figure. 1 User selecting player model in order to move to a selected tile using the new button implementation

Player Attack using Item(s)

The player will be able to attack in their turn when they select an item (categorized as a weapon type). In order to acquire a sword (item), the player must find it in the dungeon first; then, they are able to use it in the next turn (Figure. 2) (Figure. 3). The details on how the sword item works and code implementation are discussed in devlog 3.1. 

Figure. 2 Player pick up a sword (item). In the following turn, player tried to attack but is unable to as there does not exist any viable target (enemy)

Figure. 3 Player uses the sword (item) to attack a slime (enemy). The green highlighted tile indicates that there exist a valid target (enemy)

Enemy Movement and Attack

In this game, we implement a 'naïve' AI to the enemy, which only goes to the player (as a target) and attacks the player if it is in range. We only implement one type of enemy with two different sprites ( a bat and a slime). Inside the enemy (prefab) game object is a collider2D, rigidbody2D,  'naïve' AI script, Health script, enemy info script, and enemy attack trigger script. 

The info script contains basic enemy information (damage, health). The Health script is used to alter HP when the player hits it. The attack trigger script is to help deal with the player/enemy, not dealing damage to self when attacking each other.  The KIT109 tutorial code inspires all of the script implementations here. However, we must change many things to make it suitable for our game.

The 'naïve' AI script will make the enemy move/attack. The enemy will only attack 75% of the time when there is a player game object in its attack range (Figure. 4). The movement part is 'naïve'  since it only goes to the nearest tile with respect to the player game object (Figure. 5 ). The KIT109 code inspires the code/implementation of this AI. However, much extra code is needed to make it fit the grid-like style movement.

Figure. 4 Enemy attack player in range

Figure. 5 Enemies 'naïve' AI movement towards a player

Player and Enemy Combat system

In 'Into the Mist,' the combat system is inspired by chess grid-like movement and D&D combat design.  The combat system is turn-based, as shown in (Figure. 6).  The code for the turn-based system uses an enum battle state, which will keep track of whose turn it is. The game stops when the player's HP reaches zero. The code for the turn-based system is inspired by my previous text-based dungeon crawler I made for the KIT107 assignment ( java programming language). To implement the code, We use YouTube tutorial videos as a reference [1] and lots of trial and error.Figure. 6 Turn-based combat/gameplay demo


Improvement and Alternative implementation

There are a couple of improvements in mind. The main improvement is the player's attack; since we only have a sword here, it is pretty easy to make the player go to the enemy and swing the sword. However, in the future, we plan to add ranged weapons such as a magical staff and bow, so making a better UI and code structure for all the items and inventory is a priority to make it scalable with different items. To improve the enemy movement, we could implement A star (a path-finding algorithm) to make the enemy find the best route/path and avoid getting stuck at a corner.

As for alternative implementation, changing how the code is structured for the inventory system and items with alternative options might be a good idea to make this game scalable with lots of different items and enemies.

Feedback from Peer Review

I got many feedback and ideas from other people, and the feedback was mainly positive. However, some are insightful and might be able to make the game better:

Add animations when an enemy or player is getting hit

I agree with this feedback, as adding animation when getting hit can increase gameplay visuals and avoid confusion when playing the game. I will probably add a simple state of taking damage in the animator for both the player and enemies.

Add a health bar to the enemy and item description.

I am not keen on this idea, as I want to make the enemies and environment as challenging as possible with the lack of information, which makes the game far more complex and challenging. However, describing the items and some information about the enemies would be good. We can use a UI that pops up when the user's mouse hovers over something. 

Reference

[1] Create a grid in Unity - Perfect for tactics or turn-based games! Part 2. (n.d.). Www.youtube.com.

Leave a comment

Log in with itch.io to leave a comment.