- Home /
 
2D flash health and damage system
Hey, i would really appreciate some help! Just creating a 2D platformer and would love to implement a damage screen when the player gets hurt as well as a health screen when the player picks up health items. I have created two images in Photoshop with transparent centers and followed a simple tutorial on youtubeCharacterHealthTutorial, although the code doesn't seem to be working.
I have resized the images onto my canvas inside of the game and added a simple script to each image, although there is errors everywhere and being new to unity i am a bit stumped on how to fix it. Here's the Health image script:
public class HealFlash : MonoBehaviour public void HealFlash () { if (healing) { HealImage.color = healFlashColor; } else { HealImage.color = Color.Lerp(HealImage.color, Color.clear, healFlashSpeed * Time.deltaTime);
 }
 healing = false; 
 
               }
Damage Image Script :
public class DamageFlash : MonoBehaviour
 public void DamageFlash()
 
               {
 if (damaged)
 {
     DamageImage.color = damageFlashColor;
 }
 else
 {
     DamageImage.color = Color.Lerp(DamageImage.color, Color.clear, damageFlashSpeed * Time.deltaTime); 
 }
 damaged = false; 
 
               }
Would appreciate any tips on how to get this to work! Kind regards, Chantelle
Your answer