- Home /
How do I change the wrap mode on an animation?
This is probably the stupidest question ever asked on this forum, but I can NOT figure out how to change the wrap mode for an animation I made. I just want an object to rotate from 0 to 180 degrees (which that part works fine), and then back again, using the Ping Pong wrap mode. Except, I can't find the option to change the wrap mode to Ping Pong.
Shouldn't the option to change the wrap mode be where the red circle is? And if not, how do I change it? I feel like an idiot asking this but thank you for any help in advance.
Edit:
I should also add that I am using the latest version of Unity, 4.3. Maybe the interface changed or something. But I still can not figure it out... am I just missing something obvious?
From 2014, with the "traditional" Animation window,
in your Inspector of the object in question (not the animation, the object
You must select the DEBUG option from the tiny menu at the extreme top right of the Inspector panel
.
then you will clearly see "Wrap $$anonymous$$ode" on the animation component in Inspector.
Silly eh!
Answer by el-santia93 · Nov 28, 2013 at 04:27 PM
you could do it with script real easy
gameObject.animation["animationName"].wrapMode=WrapMode.PingPong;
Thanks for the response, but I probably should have specified. I tried this already, and the problem was there is no animation attached to the object, only an animator. If I add the animation to the object, the script just gives me a NullReferenceException and continues to act the same way it did, without the Ping Pong wrap. If I don't add the animation, it just tells me it can't find an animation object, because I only have an animator. I really think it should not be this complicated, I think it has to do with the 4.3 update.
Any ideas on how I could fix that problem? Thanks again.
I don't know about 4.3 but on 4.1 when i had this problem here's what i did click on the the model itself(.blend,.fbx,etc) then in the importer settings click rig. select legacy under this option and apply.now click animation u can now change the wrap mode of your animation. under the model tab you will see that your model now has an Animation component. Hope this helps
Well, I am fairly certain you just solved my problem because I remember seeing something in the console about Legacy, but I wasn't sure what it meant. Doing this will mean I have to change a lot of things, but I'm going to mark your answer as correct because I am pretty much positive that it will work. Thank you very much!
Answer by apple92 · Nov 28, 2013 at 04:29 PM
You can change the Wrapmode in your Inspector Tab. Navigate to the Animation file and select it. If Wrapmode is greyed out, select the Asset which contains those animations and then click on the Animations tab in the Inspector (There are Model/Rig/Animation tab for imported Objects).
It can also be changed via Script on runtime: http://docs.unity3d.com/Documentation/ScriptReference/WrapMode.html
Answer by gordeszkakerek · Apr 21, 2014 at 03:08 PM
Here's my tutorial video: https://www.youtube.com/watch?v=3gp4rGO8vAA
The video is unavailable .. in australia at least.
Answer by demented_hedgehog · Jul 11, 2015 at 02:39 AM
Things have changed since 4.3 (there's a difference between the legacy and new systems)...
http://answers.unity3d.com/questions/580365/wrapmode-option-not-available-in-unity-43.html
Answer by rooster · Jun 18, 2019 at 04:27 PM
I've been doing this the hard way for years and just figured out a simple clean way to do it that builds on the answers here. I'm using Unity 2019 but I suspect it would work in earlier versions.
Create an animation clip as usual
Select the clip in the project and turn off the Loop Time flag
Add the animation clip to Animator twice. Name the two states "in" and "out" or whatever works.
Set the speed on the "out" clip state to -1
Play the states normally in code
E.g.
Animator anim = GetComponent<Animator>();
anim.Play("in"); // to play the forward animation. It will hold on the last frame of clip
anim.Play("out"); // to play the backward animation. It will hold on the first frame of clip
Your answer

Follow this Question
Related Questions
Can I make animations snap to a frame? 1 Answer
Animation wrapmode in mechanim? (hip rotate and stay) 0 Answers
Single Time Animation Play 1 Answer
Programmatically created AnimationClip will not loop 2 Answers
Animation Wrapmode - once the value is set in code, can it be changed behind the scenes? 1 Answer