Corona-cation (Day 4)

Git Commit: 976a232

"Added first person HUD"


Added first person HUD:

    Still no updates on the main design doc, so today I have decided to finally tackle UI. For the main reason that it was getting really annoying having to do print strings and 'watch this value' to see if my code was working the way I thought it was.
    I started out with health. Simple enough as it was consistent across all players. My goal was to have a single widget blueprint that would work across all players regardless of their class. Just hiding and showing certain elements that were relevant to the class that the player is. After health though things got a whole lot more complicated. I wanted to have:
  • Mana bar (cleric only)
  • Ammo (sharpshooter only)
  • Main attack cooldown indicator (different timings per class)
  • Special attack cooldown (same story)
  • Revive indicator (while writing this I realized I forgot to add this one)
The mana bar was similar to the health bar just class specific; no big deal. The sharpshooter ammo, same thing just in text form for now. Where things got difficult was the elements that had to follow a time. The way that I had been doing attacks like these that needed a cooldown was just to delay for x seconds then open a do once command. This completely screwed me when I needed to get the value of the remaining delayed time for the UI. The only other way I could think to do it was the way it was done for the creative jam. This was to have a custom timeline for each attack that on update would change a float value that could then be used to make the UI change. I greatly disliked this though as it was cumbersome to change timings and was unnecessarily large in the blueprint editor. 
    After googling around for a bit I found the answer to my problem; "SetTimerByFunctionName". It was absolutely perfect, allowing me to execute functions on any object after a set duration. On top of that, if you have a reference to the timer you can get the time elapsed or remaining which was exactly what I needed for the UI.
    The only challenge now was to refactor all attacks and anything using delays to work with the new timer system. This was a pain but well worth now that it's done. Also during this refactor I made primary and special attacks have more consistent functionality across the classes but that's less important. The current widget looks like this:

Comments

Popular posts from this blog

Polishing the Foundation

Progress Update #13

A New Chapter