Tuesday, 21 January 2020

Scripting Health Animation

In Silent Hill the only visual representation of the player health is in the pause menu. Its here the player can see the state of their health and do something about it.



I've managed to code and replicate this exact affect with a simple png image:



It is quite customisable and optimised! At first this effect was challenging to create. In Unity for UI its mostly text and images, but images dont allow for much coding. this is when I noticed Images can also use materials. With a material I'm able to set the offset of the image while keeping it in place.
I did encounter an unforeseen error with this too. the effect is done with Unitys timescale using an incremental float. But the whole "Pause" system for Unity also uses this timescale effect too.
So when I pause the game because the timescale is now 0 and not being incrementally updated, the effect will no longer work. Though I found out I can use the same timing system but with an alternative function named unscaledTime, practically does the same but still continues to count even when the game's timescale is set to 0.

Only thing I need to consider next is changing the colour of the menu buttons too, to reflect the state of health.

No comments:

Post a Comment