private bool alreadyFading = false;
Then
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Teleporting Object")
{
if (!alreadyFading) StartCoroutine(Teleport(-3, 3, 5f));
}
}
And
IEnumerator Teleport(float from, float to, float duration)
{
alreadyFading = true;
var timePassed = 0f;
while (timePassed < duration)
{
var factor = timePassed / duration;
var value = Mathf.Lerp(from, to, factor);
material.SetFloat("_DissolveAmount", value);
yield return null;
}
material.SetFloat("_DissolveAmount", to);
alreadyFading = false;
}
Using a break point it's getting to the Teleport function but it's not changing the values from -3 to 3. It does nothing to the shader to the property _DissolveAmount.
I want it to change the value from -3 to 3 with duration once not ping pong. but it's not just it's just don't do anything.