Hello Guest

Author Topic: Repeating a single frame sprite  (Read 3333 times)

notsoobvious

  • Newbie
  • *
  • Posts: 6
    • View Profile
Repeating a single frame sprite
« on: September 12, 2013, 02:01:47 pm »
Hi all, I've just looked over the API for Animated Sprite and couldn't find the function (or clues) on what I'm doing wrong. What I want to do is repeat my sprite during some behaviour (i.e. keep it locked in a jump pose whilst it's jumping). The code is:

Code: [Select]
        if (Input.GetKey("space")) {
           
if (!this.motor.IsGrounded()) {
            if (!anim.IsPlaying("jump")) {

anim.Play("jump");
            }
}
                // The delegate is used here to return to the previously
                // playing clip after the "jump" animation is done playing.
anim.animationCompleteDelegate = HitCompleteDelegate;
        }


Which looks functionally correct (to me) but the Animated Sprite doesn't hold the pose and can "walk on air" if you like. I've tried replacing the Grounded if to a while but Unity blew up.

I've tried playing with the Sprite Animation clip editor settings between single/loop/creating more frames etc., but this doesn't seem to work.

I've not tried simply making a long looping animation of the same sprite because this seems like a philistine way of approaching it (if it does indeed work).

Please let me know!

notsoobvious

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Repeating a single frame sprite
« Reply #1 on: September 12, 2013, 07:45:18 pm »
Never  mind - I just solved it by removing the update function and using co-routines instead.

Works a charm  ;)