Working with tiles and managing players

So with basic collision detection added, I started looking at a couple things that involved much more C# scripting than anything I did on the project previously. Anyways here is the latest.


So what’s different? Well 3 things.

I wanted more tiles on the screen, so I zoomed out. It was fairly simple, just one setting on the camera.

Next, while I found being able to paint tiles onto the screen directly in Unity to be convenient; I wanted to have a little more control over the tiles on the screen. For that I spent time figuring out how to add tiles through scripts. Or, more accurately, straining my eyes on the documentation and banging my head against my desk while missing the completely obvious answers to questions I had. Questions like, “how does one create a tile on the tilemap, if a tile is a necessary parameter?” The answer is, of course, you just create the tile separately and then fix it to the location you want in the tilemap.

So with that figured out, I replaced the old terrain with a 32 by 16 square of grass. All the terrain was created by a script. The code wasn’t pretty and I’ll be revisiting it later to make it better, but instead moved onto the third task.

Previously, my keyboard input directed the object on the screen called player to move it around. However I’m not going to only be controlling that one single player. Like any good rpg game, I want to give keyboard input to other characters. So I added a new class that had a list for all potential characters where I can get references of whichever of them is currently getting user input. To test it, I promoted the npc to Player2 and added a switch player button on the top left to toggle change the active player. It ended up being good practice working with Unity game objects.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s