First Android Game - Part 12 - Enemy Life Point Aug 8, 2023
This is part 12 of making my first Android Game. If you missed part11, you can find it here I want to display enemy's lifepoint above the enemies so the users know how much damage they need to apply. My first attempt was to add a slider and text. However that looked very messy and took too much space So I removed the slider and only used the text The life point is displayed by setting TextMeshProUGUI text to the current life in Awake() As well as in OnTriggerEnter A lifepoint canvas prefab is created and attached to each enemy. The text size needs to be adjusted for each. The canvas is set to world space, and the canvas layer needs to be set so that the life point text is in front of the background but behind the scoreboard I wanted to add some sort of color change when the enemy gets hit such as what operation graduation does here. Or even animation. However, while I was searching up for ways to get a response. I noticed that in Evasion here, they make the lifepoints appear only if the enemy gets hit. This would help me resolve the mess I mentioned at the beginning!. So first thing in Awake is to disable the lifepoints gameobject - text and slider Then update the lifepoints and call a coroutine if the lifepoint is greater then 0 The coroutine will enable the lifepoints slider and text. After x amount of seconds it will disable the the lifepoints. Note that the coroutine is only called if the lifepoints is not enabled Here is the result. It is not as messy! See the next blog part 13 here
Recent blogs See all blogs