Skip to content

LMAG – Proof of concept

Okay, so last time I set out to make my own game. And things have been going great! I managed to hack together a nice proof of concept of my upcoming game.


Sweet right? The idea of the game is to explore a castle through a series of doors, except that you have no indication of the destination of any door. As  you progress through the levels, the castles will get more complicated and new challenges will appear.

I already have a few crazy ideas in my head, and I’m going to be talking about them in future posts.

But for now, let’s concentrate on the actual coding…


A huge part of the game relies on doors, and I made sure that this part was easily manageable. Each door is a GameObject and it’s naming defines it’s behaviour.

Here is the list of doors on the level above:

  • DoorA0
  • DoorA1
  • DoorB0
  • DoorB1

So DoorA0, will teleport to DoorA1 and back to DoorA0. But here’s the trick, if I add DoorA2, the pattern transforms into DoorA0 > DoorA1 > DoorA2 > DoorA1 > DoorA0.

Doors, moar doors!

This one’s tricky; I had to find a way to detect the collision between the player and the doors. I naturally turned to Physics2D.OverlapCircle().

But! For the function to work, the door needed to be a collider. And if the door is a collider, well, then I can’t get in!

So, I came up with this trick (I love how gamedev is 1% code and 99% hacks). I created a circle collider with radius 0.1 and Y position -0.1. That way the collider is just bellow the feet of the player and I can boost the radius parameter of Physics2D.OverlapCircle() to detect the presence of the user.

Big bugs, small fixes!

From the moment I got my door mechanisms to work, I was plagued by a bug. When the player would use a door, he would teleport to and from multiple times.

Since the Up key is used to activate doors, I quickly guessed that the keyboard input was being fired through multiple frames. And I was right!

I tried solving the issue by adding a delay to the teleportation function, learned about Coroutines on the way, only to realize that the real culprit was this line:


Which I changed to:


Indeed, GetKey gets fired as long as you hold the key down. While I only needed to teleport the user once the Up key was released.


To conclude,  I have to say I’m quite impressed with Unity. They managed to put together an amazing piece of software. Of course it has some weird behaviours at times and it crashes once a while, but there’s something that lets you know that this was made by gamers for gamers!

* LMAG = Let’s Make A Game

Published inWeb
Twitter Profile Picture

Jevin Sew

1645 Tweets
274 Following