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.


Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s