- Home /
Animation Wrapmode - once the value is set in code, can it be changed behind the scenes?
I have an animation controller class that I made, for a character that runs around and jumps. All of that works fine. I decided to add a sword slash. I put in the animation, then put in this code in the start function of the animation controller script.
var oneHandSwordAnim = animation["up_sword_action"];
oneHandSwordAnim.wrapMode = WrapMode.Once;
oneHandSwordAnim.layer = 3;
I would think that would set the wrapmode for the animation for any further time I felt like using it. But in the update when I play that animation, it loops anyway. I looked in the debugger and the wrapmode was set back to loop. Is there anything that can change the wrapmode on animations like that out from under you? I use a similar technique in the jump animation and it works fine.
Thanks!
It's possible. I checked all the other ones, and their wrapmodes seemed right. I did have an line of code setting the default to be loop early on in the controller, I'll try taking that out and see if it helps.
Answer by Andre-Odendaal · Dec 31, 2012 at 09:16 PM
I found the same problem and the solution I've used is to do it the other way around. On the model set the Animation Wrap Mode to Once which will apply to all animations and then set the animations that need looping in script (i.e. walking, idling, etc).
That does seem like a good idea. It's all moot now that I'm using $$anonymous$$echanim ins$$anonymous$$d though.
Your answer
![](https://koobas.hobune.stream/wayback/20220613080550im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Wrap Mode in animator not working properly 0 Answers
Once Animation Wrapmode v4.3.3 0 Answers
Animation Wrap Mode Usage? 1 Answer
Clamping an animation does not work. Help! 0 Answers
Animation scripting problem! 0 Answers