#Animation play twice?

1 messages · Page 1 of 1 (latest)

late moat
#

For every frame nav.remainingDistance is less than 0.07f, you are starting another coroutine, and coroutines stack so it may actually be playing a lot more than twice but maybe only appear as if its happening twice - you could try storing the corotuine in a variable and resetting that variable before starting a new one, I typically do something like this:

Coroutine co;

void DoTheThing()
{
if(co != null) {StopCoroutine(co);}
co = StartCoroutine(Example());
}

In that example, youd call DoTheThing(); instead of StartCoroutine(Example()), which will make sure if there was a previous coroutine running, that previous one gets stopped before starting another

limber socket
#

tnx i did this

#

if (nav.remainingDistance< 0.1f)
{

        DoTheThing();
    }   
}


void DoTheThing()
{
    if (co != null) { StopCoroutine(co); }
    co = StartCoroutine(ExampleCoroutine());
}
#

it works better but again did it twice

#

it is becouse of update.... :/ i guess i have try your thing with a trigger maybe will work