x


Animation timer in c#

Hi,

I'm new to programming. Was just wondering if anyone would know how to have a biped with an animation "punch" play every 2 seconds.

more ▼

asked Jan 31 '12 at 11:41 PM

kevinharte gravatar image

kevinharte
1 2 3 4

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

2 answers: sort voted first
private float lastPlay;   //last time animation was played

void Update () {
   if(Time.time - lastPlay >= 2) {   //if its been 2 or more seconds since last play
      lastPlay = Time.time;   //reset last play time to current time
      animation["punch"].Play();  //play "punch" animation
   }
}
more ▼

answered Feb 05 '12 at 08:09 PM

gregthegeek gravatar image

gregthegeek
16 4 4 5

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

Thanks man!

more ▼

answered Feb 29 '12 at 09:12 PM

kevinharte gravatar image

kevinharte
1 2 3 4

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

x4157
x347

asked: Jan 31 '12 at 11:41 PM

Seen: 790 times

Last Updated: Feb 29 '12 at 09:12 PM