Clarity Update - Nameplates - 6/3 to 6/10
Salutations dear blog reader~
Haku, c'antik (hello friend)
In my effort to streamline and add clarity to the game I realized that whereas I had an enemy stat indicator in the lower right, it would be much clearer if it were directly above the target and visible not just for the current target but all enemies. I've also color coded green/yellow/red for friendly/neutral/enemy respectively. At first I thought that I would make a world space canvas per enemy as part of the enemy object and have the canvas simply face the camera. Then I realized that this sort of feature could be implemented as a single screen space canvas, in a single pass, as long as you could figure out exactly how to project the object position from world space to screen space.
I started out by adding methods that ships could call on warp-in and warp-out/destruction to register or unregister themselves with the canvas manager. Registering themselves tells the manager to start tracking their movement and to instantiate a proper nameplate for them.
Next, because I didn't want the nameplate to appear exactly on top of the ship but rather slightly above it I needed to get a Y offset. However because I want this offset to be sensitive to the actual pixel height of the screen and not be a static number I instead make it a proportional offset relative to the screen height. In this example shipIndicatorOffset would be something like 5%-10%.
Next we get the world position of each registered ship and get it's screen position. Once we have the screen position we find that same position within the context of our UI drawing canvas. Once we have this position we can use it to set the position of the name plate, adjusting slightly upwards using the proportional offset.
There we go, nameplates that are rendered on a single screen space canvas but properly follow their world space targets.
Thank you for reading this far, kaqhina's (I am grateful) 💖
Kiwana'n (goodbye for a bit)