itch.io is community of indie game creators and players

Devlogs

Devlog - Player Movement

Into the Mist
A browser game made in HTML5

Devlog one: Player Movement

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

Player Movement

In this game, the player follows a king's movement in chess; that is, the player can only move to adjacent tiles. To move the player, you would first press the left mouse button on the player character (to select it), hover your mouse over a tile you want, and press right-click to move. 

The simple level/grid map shown below uses a tile map system; I separate the wall tiles and path tiles so that we can know which tiles are selectable and which are not. On both tile map game objects, I added RigidBody 2D with the Body Type set to Static (so that it stays in place) and Composite Collider 2D. 

The player game object has a Sprite Renderer, Box Collider 2D, and the player movement script. The code for the movement was largely based on an online/YouTube tutorial [1], though I need to add a couple of codes to change the highlighted tile color and how to make the player follow a king-piece movement in chess. I also added a script to detect when a character is selected using Raycast. The code is inspired largely by the KIT109 'Raycast' tutorials.

Figure. 1 Player move to adjacent tiles which are highlighted green.

On the other hand, If the tile is highlighted red, then the character will not be able to move to that selected tile (i.e., outside of the allowable range) (Figure. 2).  

Figure. 2 Player are unable to move when the highlighted tile is red.

Improvements and Alternatives Implementation

One specific improvement is to add animations to the character when moving. This would make the character/player's movement more fluid, which would be nicer to look at for long periods of playtime.

I considered some other alternatives when implementing the movement system. One that comes to mind is to use an invisible game object that will move according to the selected tile and make the character/player game object move there, which is similar to what I implemented. Furthermore, we can use the input system in Unity to detect if a character (Box Collider2D) is clicked or not. I'm not too sure if there are more alternatives for implementing the grid-like movement that I want for the game.

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.

I certainly agree with adding animations to make the movement less clunky as I mentioned in the improvement section. To do this, I will add the animations and animator components to my character. I will add an idle animation and a moving animation.

  • Make the highlighted tile disappear when your mouse is hovering over the walls/obstacles.

People notice that when selecting tiles, the highlighted tile does not disappear when we hover over a wall (Figure 3 ). This can create many problems. I think adding a bit of extra code to make the highlighted tile disappear when your mouse is hovering over the walls would make the selection process of the player feel nicer and reduce miss-clicks. To do this, I will add a simple if statement to detect whether the mouse is hovering on a wall/obstacle.

Figure. 3 Highlighted tile did not disappear when mouse is hovering on the wall

Reference

[1]  Unity 2024 Tutorial: SIMPLE Grid-Based CLICK Movement [Part 1]. (n.d.). Www.youtube.com. Retrieved April 26, 2024, from

Files

  • Build.zip 3.2 MB
    Apr 25, 2024
Leave a comment