x


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?

more ▼

asked Oct 24 '11 at 05:15 PM

Dreave gravatar image

Dreave
122 82 94 96

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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 :)

more ▼

answered Oct 25 '11 at 10:20 PM

benjimazza gravatar image

benjimazza
102 23 34 37

(comments are locked)
10|3000 characters needed characters left

Try adding this to OnStart:

 animation["Animation Name"].wrapMode = WrapMode.Loop;
more ▼

answered Oct 24 '11 at 06:07 PM

gruhm gravatar image

gruhm
121 1 2

Where would I add this? This is my script

function OnStart ()

{ if ( Input.GetButtonDown("S") ) { transform.animation.Play("walk_backwards"); } }

Oct 24 '11 at 09:17 PM Dreave

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/Manual/Animation%20Scripting.html

It has some great examples.

Oct 24 '11 at 09:29 PM gruhm

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?

Oct 25 '11 at 08:08 PM Dreave

@gruhm Page Not Found

Feb 18 at 11:40 AM ina
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5099
x3807
x3753
x296

asked: Oct 24 '11 at 05:15 PM

Seen: 6615 times

Last Updated: Feb 18 at 11:40 AM