Hello Guest

Author Topic: Trying to control animation frames: Version 1.92  (Read 4650 times)

Madrayken

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 21
    • View Profile
Trying to control animation frames: Version 1.92
« on: June 05, 2013, 12:48:26 am »
Hi folks,

I have a character who walks left and right while bobbing up and down a little based on a nice flattened sine-wave. I am trying to use SetFrame() to pick the frame based on how far through the sine wave he is. I do this every Update() in order to ensure that he's always forcing a specific frame.

This seems to work while I stick to the same 2-frame clip. As soon as I switch to another clip, he starts automatically looping his animations at 30fps, and never returns to the original, specific behaviour, even when he returns to that particular clip. I want TOTAL control over which frame is playing at any time. Is this a bug?

Furthermore, does SetFrame start from 0 or 1?
« Last Edit: June 05, 2013, 01:30:20 am by Madrayken »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Trying to control animation frames: Version 1.92
« Reply #1 on: June 05, 2013, 10:01:29 am »
Doesn't look like a bug. How exactly are you switching clip? If you call Play, then obviously it'll start playing. Depending on the script execution order, this may happen before or after your script runs so its not exactly a foolproof way of going about it.

You might want to call Play, then Stop immediately after - this will set the currentClip, but not play the animation, at which point you can SetFrame as much as you'd like :) SetFrame starts from 0.

Madrayken

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Trying to control animation frames: Version 1.92
« Reply #2 on: June 05, 2013, 03:19:49 pm »
Aha! Thanks for that. It worked. Out of interest, how do people usually control the speed of a walk cycle when the character's speed is variable? Getting it to synch based on constantly tweaking the fps seems exceedingly complicated.