2020.1.15f1 How to set animations "LoopTime" to false from script
Hello everyone!
I spent good time trying to find any solution but everything I find seems to be for older versions or something? Basically I want to set an AnimationClip.LoopTime from true to false or vice versa from script. I want this to let the object finish the currently running animation cycle.
If I just set the Animator to enabled=false like it's said in some posts, the animation stops right away of course and that leaves the object off position.
Somehow it has to be possible to just set looping=false and avoid having to create additional complicated transitions or something with the Animator?
Any help/hint is greatly appreciated!
Answer by Carsten-Germer · Dec 03, 2020 at 09:39 AM
I was rolling this through my head yesterday evening afk and I decided adding an event to the animation clip would be the best solution.
If anything depends on the frame the animation is in (in my case being back at its original position) use an event and notify the puppeteer script.
It's easier wo write, understandable when seeing it later and most of all much cleaner.
Answer by xpcrepair23 · Dec 02, 2020 at 04:47 PM
Try creating a parameter called Loop in the animator and after playing set to false. When playing just set a AND if Loop = true of some sort.
I get the notion but I would need clarification on "When playing just set a AND if Loop = true". How would that control looping of the AnimationClip?
Like on your method, ex:
Void Walk() {if (moving && loop) Anim.Play(clipname); loop =false; //so it stops looping
}
void new$$anonymous$$ethod() {loop = true code//
}
How would me setting loop=false in my script stop the looping of an AnimationClip? Afaik that is not how that works. Would be nice, sure, but I don't see it. An AnimationClip that has set LoopTime= true loops forever when played with myAnimator.Play("AnimationName")