Slender Static / Noise script?

Hello dear community!

I’m new to Unity and I’m going to do a Slender Kit.
But now I’m stuck at the static noise effect.
It’s hard to explain how it works, but I’ll try…

I am using NoiseEffect.cs from Image Effects.
The starting value of the noise effect should be 0.
When the player’s health (100) decreases, the noise effect’s value should increase.
The maximal value of the noise effect can be 5.

I tried to do a script, but this script just decreases the noise effect, which starts with the value 5, when the player’s health decreases.

I just paste the script:

    var HealthScript : PlayerHealth;
    var NoiseScript : NoiseEffect;
    var NoiseMultiplier : float = 20.0f;
    
    function Update () {
    	NoiseScript.grainIntensityMin = HealthScript.health / NoiseMultiplier;
    	NoiseScript.grainIntensityMax = HealthScript.health / NoiseMultiplier;
    	}

Can anyone help me?

  • Regards, starscratcher

PS: Sorry if anything’s spelled wrong, my English isn’t that good.

Well if this script makes the noise decrease then turn the positive multipliers into negative e.g -20 to see if this increases the noise level

If NoiseMultiplier is for example 5.0 , you could do something similar to this:

NoiseScript.grainIntensityMax = (NoiseMultiplier / 100) * (100 - HealthScript.health);

It starts off at 0, because the players health is 100, and increases as players health decreases. The maximum value would be the NoiseMultiplier.