Featured
Posted in GameDev, Life Updates

I Want To Make A Game

After finishing a Game Development and Design course, I am ready to make some games of my own! I thought it would be interesting for you all to be able to read about my process – how I approach a project like this, where do I take inspiration from… and to get updates throughout the process until the very end result (if I will succeed and not surrender in a few months).

Continue reading “I Want To Make A Game”

Unity 2D Grid System – It’s THAT Easy!

Today I learned about Tilemaps in Unity – a simple way to build a grid system for your game! This is something that I will be implementing in my game, a 2D RPG, in order to have my player pickup or interact with nearby objects. This can be also useful as a way to place any trees, buildings or anything else in a nicer way, snapped to a grid.

So Unity actually has a built in tilemap package, and you can make a grid with a simple click

By the way, my source of information for this part of the project is this youtube video by Tamara Makes Games.

There are way too many cool things in Tamaras tutorial that I will not be doing, but I just want to point them out, because they are cool:

  • How to make rules for the tiles, placing different sprites on different conditions, such as edges to the ground.
  • Loot to show on top of the ground
  • Scriptable Objects for tools and for tiles that are interactable with those objects (I might need this one later)

Similarly to Tamaras’ tutorial, I’ll be making two tilemaps – one for the actual grid, and one for the selection of the mouse.

And after a few, well not so few, tries – I got me a tile palette:

Named New aaaaaaaaaa, which indicates just how stupid I felt when I realized that for the last 10 minutes I was trying to figure out why this isn’t working when all this time my sprite was set to single…

Don’t forget to setup your sprite! It should be on multiple, and use the sprite editor to divide it to cells.

At last! my Creation!

This is of course just an image I got online, we’re not focusing on the art for the next… month probably.

So… what was I trying to do with the tiles? Right. Highlighting the actionable tile next to the player.

I want the tile that the player is facing to be highlighted, but if the mouse is on a tile near the player this tile will be the one highlighted, no matter where the player is facing.

For this I am going to save the direction in which the player was last walking towards.

And just like magic, the little snowman is showing us the selected tile.

Now for the mouse selection – if the mouse is in the nearest cells to the player, the selection will be where the mouse is, regardless of the direction the player is facing. (by the way, I hope it makes sense that our square is facing the direction it is walking towards, even though it doesn’t have a face yet 🙂 )

After giving it a lot of thought, I figured the best way to make the selection stay on the last selected space until it is moved again, or until the mouse is changing it, is by saving a bool indicating whether we moved again or not, and if not, we are saving the last cell we faced as the cell that the mouse was on, not recalculating the cell until we moved again.

This is kind of tricky to explain, but I hope looking at the code will help:

Now I am done with the selection, the code is starting to feel messier and I don’t really know how to improve it. I am just learning and I would love to hear any tips or corrections, better way to do things, or just whatever you want to comment down below.

Have a nice day!