Search Unity

How to slowly decrease saturation as the player takes damage?

Discussion in 'Scripting' started by the_Bad_Brad, Sep 26, 2017.

  1. the_Bad_Brad

    the_Bad_Brad

    Joined:
    Nov 2, 2014
    Posts:
    278
    I don't know how to manipulate the Grayscale image effect to slowly fade in as the player takes damage

    Here is a code I got from a friend I just need to modify it. This script will activate when the player's exosuit is in critical condition so the player will begin taking damage.
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class ExoCritical : MonoBehaviour
    4. {
    5. public int maxHealth = 100;
    6. public int currentHealth = maxHealth;
    7.  
    8. public void TakeHit(int amount) { currentHealth -= amount;
    9. If (currentHealth <= 20)
    10. {
    11. //Saturation fade out start
    12. }
    13. If (currentHealth <= 10)
    14. {
    15. //Noise filter activate
    16. }
    17.  
    18. if (currentHealth <= 0)
    19. {
    20. currentHealth = 0;
    21. //Display text KIA
    22. }
    23. }
    24. }
     
  2. RoMax92

    RoMax92

    Joined:
    May 29, 2017
    Posts:
    135