Saturday, 19 March 2016

Adding Scenery Objects and UI -- Late Blog Post 3

The following week after I learned the basics of Blender (the 3D Modeling tool, that is), I started making scenery objects within our game. The code for scenery objects is similar to enemies, only these objects don't need to move. To make them fully destructible they needed to have a health bar and the player has to be able to attack them. Everything was going great until I came across a big issue.

Once scenery objects are on the board, how can I click on the tiles behind them? Or better yet, what if the player is behind scenery objects? Or Enemies? Or Tiles? I needed to find a way to make the trees and rocks I was creating "invisible" to the player when she/he hovers over them to keep normal gameplay intact.

The trick was using Unity colliders for the scenery objects. Colliders register the mouse hovering over them. Incorporating that knowledge with my idea of transparent scenery, I could turn the scenery objects invisible by altering their material. The problem that came with this was a Collider also blocks the mouse from clicking on anything behind the Collider; I could not click a tile behind a scenery object because the scenery's collider was stealing the mouse input away from the tiles behind it. I had to turn the collider off in order to access the tiles behind, but then that made the tree reappear because the mouse was no longer hovering over the collider! The result, as one could imagine, was a strobe effect of scenery objects (appear, disappear, appear, etc). The flashing was happening 60 times per second! It was a bug that needed to be fixed quickly.

The temporary solution was to buffer the times the scenery objects would appear, disappear and reappear again so as not to have it flashing like crazy.

User Interface (UI) was desperately needed after our first play testing session (one of the major terms of feedback we got). I had enough time this week to also create the simple UI we have now. It still needs work, but for now it shows the health of the player, the action bar, and the start of our objective tracker.

No comments:

Post a Comment