Question by 
               Daniel_Curley2003 · May 13, 2020 at 05:44 PM · 
                c#particlesystemenemy aivisualstudio  
              
 
              how to make an enemy flash when clicked on?
This is my enemy script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class EnemyDamage : MonoBehaviour {
 public int maxHealth = 100;
 public int currentHealth;
 
 
 public HealthBar healthBar;
 // Start is called before the first frame update
 void Start()
 {
     currentHealth = maxHealth;
     healthBar.SetMaxHealth(maxHealth);
 }
 // Update is called once per frame
 void Update()
 {
     
     CheckForHit();
 }
 void CheckForHit()
 {
     if (Input.GetMouseButtonDown(0))
     {
         var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
         RaycastHit hit = new RaycastHit();
         if (Physics.Raycast(ray, out hit, 5))
         {
             if (hit.collider.gameObject.CompareTag("Enemy"))
             {
                 TakeDamage(20);
                 Debug.Log("Enemy Hit");
                 
             }
         }
     }
 }
 void TakeDamage(int damage)
 {
     currentHealth -= damage;
     healthBar.SetHealth(currentHealth);
     if (currentHealth <= 0)
     {
         Destroy(gameObject);
         Debug.Log("Enemy Killed");
     }
 }
 
               }
this is used to deal damage and kill my enemy (which is a white sphere at the moment).Im wondering how i would either change the material or add in a particle effect for a few seconds to make it look like its been hurt?
               Comment
              
 
               
              Your answer
 
             Follow this Question
Related Questions
Has anyone found a way to change Shuriken particles with c# while it is in transit. 1 Answer
Visual Studio doesn't show function description 0 Answers
Enemy AI. How to make the AI chase the player by using the exact same moves as the player. (2D) 1 Answer
Setting the startLifetime of a Particle System via C#? 2 Answers
Particle Collision between particles 2 Answers