Month: September 2015

Update, a rather large one at that.

Stay a while and listen!

Right, we’ve made quite a decent progress on the game. This blog post will discuss how we implemented the various parts of the game.

Player Movement:

This one is simple. We used a RigidBody component to track the position of the player character and we use vectors depending on the buttons we press (up, down, left, right or wasd) to move the character. There is also an animator variable which is bound by a state machine which has conditions to give our player animations depending on the state of the character. As of now we only have moevement animations for the player character.

 Enemy AI. 

This is a simple AI used for the goblin prefab that will change at some point. As of now the AI will run after player if the player is within an aggro distance.

  • If player is within aggro range and out of attack range, walk towards player.
  • If player is within attack range, Enemy attacks player.
  • If player gets out of range, return to spawn point.
  • else player is too far away, go back to spawn point.

The problem with this is that you can’t surprise attack (back stab) the goblin from behind and he doesn’t have a “vision”. We’re thinking of implementing a Trigger BoxCollider2D which we will form after a humans vision. Though the enemy attack animations are still not in place and will therefor take priority.

Goblin attack is just a variable attackDamage which chips away at playerHealth variable if the goblin object collides with the player object.


We’ve put all movable game objects under a parent GameObject which contains a pause script. This script contains a boolean such that:

for each frame update in each movable object if the pause boolean is true then do nothing.

NPC Dialog

We have two String arrays for dialog. One for first time talk, and another one for all other times you talk with him. You’ve probably noticed it in some game where when you talk to a character multiple times they’ll say different things (Every oldschool JRPG ever).

The implementation of this had a lot of trial and error. We have the GUI which starts as disabled. The NPC also have a Trigger Collider, when we’re in the Trigger and press an input key (space at the moment)  we display the text box.

When displaying the text box, the text itself will be determined by a counter which iterates through the String Array. Also all the movable characters are locked from moving.

After going through the entire first array we set the currentDialog to the second string array so that he will always say something else by then. Then it’s the same process.

That’s pretty much it for this post. Though I’d like to advise every aspiring game designer to use while (loops) with caution when programming in unity. I got into an eternal loop when writing something like

// In the NPC dialog class

while(currentDialog < lastLine)


Those two lines made Unity crash to the point where I couldn’t even turn off play mode and had to close it via the taskmanager. So yeah, use while loops with caution and until next time!

Best Regards

P219 Development Team.


Update sprint one

Greetings, adventurer.

Our game is now finally starting to look like a real game. We have now made:

  • Two Testmaps with some objects for testing features
  • Player with animation and basic movements
  • Camera that is follows the player
  • Current health
  • An AI enemy that runs after when you are in sight and attack when you are in range.
  • A chest which opens when you stand in front of it and press “space”
  • NPC dialog: If you stand next to an NPC and press “space”, you can be given instructions, mission etc.


  • We have some problems to push/pull files generated by tiled2unity after using Tiled to create maps to/from git. We have now decided to only use Unity to create maps to avoid these problem in the future.


This picture show one of the testmaps when the player interact with a tree.

If you have any comments, questions or tips, please feel free to leave a comment below.

That will be all for the second post. Stay tuned!

Best regards,

Project219 development team