Hey guys!
I got a problem with a Trail Renderer not deleting it’s rendered trail when I want it to delete and reset.
I’m trying to set the lifetime to 0 and back to 9999 (to kill the already rendered trail and set a new lifetime after a short time).
So what am I doing wrong here? It’s not jumping into the 2nd if block.
void UpdateRenderedTrail()
{
if(Agent.GetComponentInChildren<TrailRenderer>().time == 0)
{
_trailTimer -= 0.1 * Time.deltaTime;
if(_trailTimer <= 0)
{
Agent.GetComponentInChildren<TrailRenderer>().time = 9999f;
_trailTimer = 0.1f;
}
}
}
Btw, putting it into Update() causes a stack overflow!