Increase Lens Distortion value problem
Hi friends. I need some help with a problem with this code. The problem is that using "MathF.Lerp" has worked for me to change values in the Vignette effect or in DOF in the past, but for some reason the same does not happen with LD. What i want is that when the player touches the collider the intensity of the Lens Distortion increases from 0 to 100 in .5f and then, back to 0 .(it could be noticed that in the coroutine I used WaitForSeconds ... but the error does not depend on this as even without that it doesnt work ). Anyone know any way to make the "Intensity" of LD value increase or decrease over time? The other things in the code work fine, even if I increase the value directly (for example: Distortion.intensity.value = 100) it works perfectly, but if I use the described form (Mathf.Lerp) nothing happens at all.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
public class Teletransportacion : MonoBehaviour
{
public Transform destino;
public GameObject jugador;
AudioSource audiosource;
public AudioClip[] audioclip;
public PostProcessVolume volume;
LensDistortion Distorsion;
bool distorsionando = false;
// Start is called before the first frame update
void Start()
{
volume.profile.TryGetSettings(out Distorsion);
Distorsion.intensity.value = 0;
audiosource = GetComponent<AudioSource>();
}
// Update is called once per frame
void Update()
{
if (distorsionando==true)
{
StartCoroutine(distorsionar());
entrarPortal();
}
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
distorsionando = true;
}
}
void entrarPortal()
{
jugador.transform.position = destino.transform.position;
jugador.transform.position = destino.transform.position;
audiosource.PlayOneShot(audioclip[0]);
}
IEnumerator distorsionar()
{
distorsionando = false;
Distorsion.intensity.value = Mathf.Lerp(Distorsion.intensity.value, 100, .5f * Time.deltaTime);
yield return new WaitForSeconds(.1f);
Distorsion.intensity.value = Mathf.Lerp(Distorsion.intensity.value, 0, .5f * Time.deltaTime);
}
}
Your answer
Follow this Question
Related Questions
get component post processing behaviour 0 Answers
Shader normals modification different in build 1 Answer
Create liquid camera effect 0 Answers
Camera Effects Applied on All Culling Mask Layer either layer is turned on or off 1 Answer
How do the "Camera" and "Main Camera" blocks work in the VFX Graph? 0 Answers