- Home /
Loop Animation In Script?
Is there anyway to make only 1 of my animations on my character loop? I thought about this as a script and looked it up on Google but I couldn't find anything, is it possible or is there some other way?
Answer by benjimazza · Oct 25, 2011 at 10:20 PM
to make it easier,, Why don't you just set the animation to a loop When you put the KeyFrames in,, Then use a simple activate animation script something like,,
function Update () { if(Input.GetKey("s")) animation.Play("walk_backwards");
// if you want to add more animations then put
else if(Input.GetKey("What Key You Need"))
animation.Play("What Animation You Need");
// Then if you wanted a idle to play it would be
else
animation.Crossfade("Idle");
{ Hope This helped :)
Answer by gruhm · Oct 24, 2011 at 06:07 PM
Try adding this to OnStart:
animation["Animation Name"].wrapMode = WrapMode.Loop;
Where would I add this? This is my script
function OnStart ()
{ if ( Input.GetButtonDown("S") ) { transform.animation.Play("walk_backwards"); } }
You're not going to want to get input in Onstart. You should be doing that in one of the update functions. The code above will simply set the specific animation to play in a loop.
If you are looking at how to control the animation you will want to look at the animation section of the documentation:
http://unity3d.com/support/documentation/$$anonymous$$anual/Animation%20Scripting.html
It has some great examples.
the documentation basically says the same sort of thing that you have said, I have tried quite a few different scripts with help from the documentation but non of them do anything, please can you help?
same ...page not found also noticed on forum ...several links to documentation/$$anonymous$$anual/ are break "Page not found "... Error s ss...whats going on.
Your answer
Follow this Question
Related Questions
Animation Scripting Help 1 Answer
Loop Animation Help 1 Answer
Trying to simply play this animation... Help please. 1 Answer