Daily Dev Blog – Player Chat, Fog of War, etc.

I missed a month of Daily Blogging.  To be honest, I’ve been a bit down on luck with the Job Market.  It’s definitely makes me a bit sad… 

Anyway, I’ve been coding in Unity for awhile and I enjoy it and there’s still so much to learn.  The Software Engineering field is just so vast that I’m a bit overwhelmed with everything out there.  Sure, I can code decently in Unity for 2D games and other projects that I’ve built, but if I were to code in something else outside of Unity, it just feels a bit foreign.  Bootcamp in General Assembly wasn’t hard to pass and get my Certificate, but that’s mostly Web Development which I’m pretty sure I can pick up again if I spend more time with it.  But that’s the thing, there’s never really enough time to learn everything and I really have a strong urge to specialize in Unity 2D games.  Seems like Employers expect one to know everything or maybe I’m just not searching hard enough.

Aside from another project that I have to do some maintenance on from time to time, I’ve been spending the other portion of my free time continuing on Building Battle of Bases (Metal Marines Inspired).  I got some Menus built to get to the gameplay portion which includes the Lobby where players connect through LAN and can chat.  There’s also a grid like preview of the map where the player can choose where to plant their base.  It’s a bit like Battleship where you plant your ships.  So aside from the Test Map, usually a player can place up to 3 Bases.

The next major thing I worked on aside from some UI adjustments have been the Fog of War.  This thing was a major pain to implement and I couldn’t find any perfect tutorial for it.  Although, implementing the Minimap’s Fog of War was a Breeze thanks to James Doyle covering that aspect in his Udemy Roguelike course.  I initially did the method of Spawning a grid of Fog Tiles per grid position.  So with a map size of 65 x 65, the screen ended up having over 4000 Objects.  Did it work?  Sure, but the framerate was horrendous.  Dropped to 20-30 Frames per second.  After a few days of fiddling with that along with trying other methods or solutions to increase the Framerate, I completely scrapped that way of doing it.  

So, I had to make use of the Tilemap somehow but I’m still pretty new to Tilemapping.  I used to actually just drag prefab objects and snap them into the scene but Tilemaps are just so much better for performance.  And it’s supposed to speedup things map/dungeon designing.  But Tilemaps does make Visualizing each tile more difficult as it seems like one Merged Object.  So I can’t click each object individually to check.  And I never understood how one can get properties of each Tile in the Tilemap.  During this road block, I learned much more about how Scriptable Objects work now in Unity.  I also got more familiar with custom classes, structs, a bit on Dictionaries and ways to reference those Tiles which helps with the Visualizing.  I haven’t really had the need to use them much in the past.  It’s still a major pain as opposed to just adding a trigger collider onto an Tile.  But since I can’t find a way to give each tile a unique collider that triggers separately, I had to go back to studying Trigonometry again and make each Fog Tile show (or not) based on the Distance from a structure for instance.  All in all, after much effort, I’m happy with the results as now it performs over 100 Frames faster than the previous method of spawning a few thousand GameObjects.  Also, shooting missiles blackens the terrain.  I just have to draw some Animations now for the Explosion!

This entry was posted in Entries. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *