I wanted to make the camera blur when health is low. I don’t know how and I need assistance.
My Unity version is 2019.4.21f1 LTS
If you’re using the Post processing stack V2 from the package manager, in a standard template project, then you can do this with a reference to the PostProcessVolume component. For example:
// Important: Reference to Volume component
using UnityEngine.Rendering.PostProcessing;
public class HealthEffect : MonoBehaviour
{
public PostProcessVolume Volume;
// Blur effect
DepthOfField depthOfField;
[Range(0, 100)] public float Health;
void Start()
{
Volume.profile.TryGetSettings(out depthOfField);
}
void Update()
{
// Focus distance is affected by current health
// Less health = greater distance to the point of focus
// = more blur
depthOfField.focusDistance.value = 100f / Health;
}
}
That’s one example. I’m sure you can build on this to affect other effects such as vignette, when on low health. @Gu3stBandit
@Llama_w_2Ls Thank you! It works!