In a strategic game such as this, its extra important that they player knows which character is which. I have done this by adding a world-space UI canvas to the base character prefab and using it to display the character's health, name and faction. The code to acquire and display this information is pretty much the same as that used in the manager script to display the acting character's details in the main UI canvas. The difference with these overhead canvases however, is that they exist in world-space rather than as a camera overlay. As such, I added code to the base character script which rotates the overhead canvas to always face the camera, ensuring the player has a clear view.
Overhead UI variables:
Overhead UI code from the base character start function:
Rotate canvas function called on update:
My other major change today, was the addition of tooltips for the ability buttons. Hovering the mouse over an ability button will now display a text box containing the ability's name and a description of what it does. Enabling the game to detect that the mouse was hovered over a specific UI element proved to be more difficult than anticipated, as UI objects, as far as I can tell, do not respond normally to raycasts in the same way that other game objects do. After some searching, I did eventually find a method which allows me to program the functionality I was looking for. I created a tooltip script, which I attached to each of the ability buttons in the UI. This uses the "IPointerEnterHandler" interface to detect when the mouse is over a button and then calls my "show tooltip" function in the manager script, passing it the name of the button. I also used the "IPointerExitHandler" interface to detect when the mouse is no longer over the button and then deactivate the tooltip.
Tooltip Script:
When the "show tool tip" function in the manager script is called, it activates the tooltip, sets its title to be the name of the ability that is being hovered over and then uses that to find and display a description of it.
Show and hide tooltip functions:
Video of the new additions:
Comments