Animation Speed Clarification

Started by SpacePirateCaine, Fri 06/02/2009 08:09:11

Previous topic - Next topic

SpacePirateCaine

Ahoy,

I'm recently working on creating a lot of very detailed animations for a project that I've been involved in, with some highly variable delays in some frames (i.e. 2 seconds here, .5 seconds there...). I'm really sorry if I've missed something, but the actual information on animation speed doesn't really seem very well documented. I know that the engine processes 40 ticks per second, so with every frame having a delay of 1 (0?), I'm looking at 40 FPS, but how does the manual delay on frames in a specific loop work into the equation?

Say I'm playing a loop with 10 frames of animation. I want the first 4 frames to be 1/10 of a second each, but the 5th frame to be 1 full second, before moving on to the 6th. At the moment, I'm setting the 5th frame with a manual delay of 40 (for 1 second), and leaving the rest with the default delay (Which seems to be 0). Afterwards, I'm animating the character with:

Character.Animate (x, y, eBlock,...) but having trouble working out what I should be choosing for my y integer. At first, I assumed it should be 4, for a default 4-frame delay, but that looks a lot slower than 1/10 of a second per frame. My question is: What is my y in relation to the delay set manually in a loop? If I run an animation with a y of 4, does it add a delay of 4 to each frame?

For some reason, it seems as though the closest I've been able to get is to animate with a y of 3, but I don't really know why, and I'd really love to know exactly how the animation system works in AGS so I can make my animation as smooth as possible in-game, and eliminate the guesswork.

Edit: I've been fiddling around with the editor - Firstly, I think I got the number 40 erroneously from watching Densming's tutorials. So assuming that the editor runs animations at 30 FPS (Which is a lot cleaner a number anyway), running at a y of 3 does make sense, if the animation speed sets the default delay for frames... but I'd still like to know if that affects the manual delay on loops? By setting it to 30, does that give it a delay of 33, or am I still way off base?
Check out MonstroCity! | Level 0 NPCs on YouTube! | Life's far too short to be pessimistic.

ThreeOhFour

Just a quick note and comment of my own:

I've been looking at trying to get an accurate figure for animations myself, regarding how long each frame takes. I initially thought a delay of 1 would mean it runs at 40 fps, but it seems like you need to set a delay of 0 to get the 40 fps (if it even is 40).

Am I correct in thinking that when a 'delay' figure is set to 1, it means the game shows that frame for 2 game cycles? It makes sense to me this way, because I've got a couple of animations running at 0 delay and they don't seem to skip frames, and also because when I tried to calculate the speed of an animation based on delay x number of frames (when I assumed that an animation running at delay 1 = 40fps) I ended up with an animation time that was about double that of what I calculated.

I assume then that if you wanted exactly one second, and the game runs at FPS, one has to set a delay of 39 for the frame? I wonder if this is the same with the Wait function.

Interested to see what comes out of this!

TheJBurger

I've been wondering this myself in the case of walk cycles.

(Sorry for the slight derail) I can't figure out how to get a character's animation speed to match up with walk speed (I've fiddled with both values for an eternity), so I've tried tinkering with the frame delays and global delays. Nothing productive came out of it, however.

ThreeOhFour

JBurger, do you mean how to get the feet so that they don't skid along the floor, or something else?

If you mean making it so that they don't skid, I generally find that I have to stick to a certain number of pixels of movement back per frame for certain animation speeds. If you find a nice medium there, you shouldn't have any problems with skidding. Ie, if I recall correctly, moving a foot 4 pixels back each frame gives you pixel perfect foot movement at Delay of 2 and walking speed of 5.

Khris

Not afaik; Movement Speed should be the exact amount of pixels between frames. Animation delay is the amount of game loops that passes between frames, so changing the number doesn't affect skidding.

TheJBurger

Quote from: Ben304 on Sat 07/02/2009 05:18:34
JBurger, do you mean how to get the feet so that they don't skid along the floor, or something else?
Yes, that's exactly it.

Quote from: KhrisMUC on Sat 07/02/2009 14:09:28
Not afaik; Movement Speed should be the exact amount of pixels between frames. Animation delay is the amount of game loops that passes between frames, so changing the number doesn't affect skidding.

Ahah. I did not know that. I set the movement speed to a value of 9 (it's a lot, I know) and it matches up with the walk cycle now, but it's really jerky and not fluid. I'm guessing the only way to remedy this is either decrease the animation speed (but then the char moves too fast) or make a smoother animation ( > 8 frames).

(Sorry, should've made my own thread.)

ThreeOhFour

8 frames should be heaps!

How big a pixel gap do the feet move each frame? You should not have a problem getting it to work well at 8 frames at all.

TheJBurger

Er, it is a 8-9 pixel movement between the feet of every frame (discounting the recoil frame). The character sprite is 36 pixels wide, so the 9px gap between the feet is roughly divided evenly for the four frames to reach 36 px and then repeat itself for 8 frames total. The movement speed of 9 matches up the feet correctly while the character walks in-game, but I think this is creating the 9 pixel "jerk" every ensuing frame (I'm assuming the engine is relocating the sprite 9 pixels every frame). I guess I should've made the character walk in tinier bounds?

ThreeOhFour

#8
Actually, yeah, that might be the issue. 9 pixels is a huge gap in foot movements, especially if you are talking 320x240/320x200 (which I assume you are). The solution, sadly, is probably to up the frame count.

(ps, by pixel gap, I mean toe to toe each frame, to make sure we're not getting confused :))

SpacePirateCaine

Hi folks,

Interesting information we're seeing here, definitely, and I really don't mean to be a pill, but I'm coming back to my thread an awful lot and just getting a bunch of questions about fine-tuning walkcycles, which though really useful information, doesn't address the question I posed when I opened the thread. I'd like to repose my original question, then when that's worked out, please do feel free to keep discussing. I do like to learn as much as I can about animation in-game.

Interestingly, KhrisMUC seems to have addressed my concern to a certain extent in a different thread that was started recently:

Quote from: KhrisMUC on Sat 07/02/2009 14:14:54
Yes, and if an animation has a lot of equal frame delays (e.g. 4), leave them at zero, then set a frame with an original delay of 10 to 6, etc., then play the animation with a global delay of 4. In-game, the frame delay is added to the global delay and you can even use negative values (e.g. -3) to change a frame delay to e.g. 1.

Can anyone confirm that the frame delay is offset by the animation speed? It still seems flawed, as I've been working with one project where I play frames at speed 2 (Where all animation frames are set to delay of 0), and it moves roughly as smoothly as an animation I worked up with a delay of 6/60 of a second.

This leads me to believe that the standard framerate is 30 FPS, and a delay of 0 is actually 1/30 of a second. Is that right?

There is an FPS counter, actually, that doesn't seem to be very well documented:
Quote from: Scorpiorus on Sat 12/04/2003 21:48:01
1. Using built-in FPS counter (Debug(4,1);) is possible only if debug mode is turned on.
...
GetFPS();
Returns current FPS speed.
But I haven't had much time to fiddle around with it just yet, and it seems to fluctuate a bit.

Does the animation speed arbitrarily add a delay of n FPS to existing Delay, where n=the animation speed integer? So playing an animation at a speed of 2 with an initial delay of 0(1) would return 3 (1/10th of a second)... Is this accurate?
Check out MonstroCity! | Level 0 NPCs on YouTube! | Life's far too short to be pessimistic.

SpacePaw

Any of you guys found a solution? I'm creating gif exporter that exports views to gifs and I need that to keep up with the animation speed. 40 fps gives something like 25 miliseconds delay.
The delay is relative to overall animation speed but what is is? a multiplier? or miliseconds? or 1/100 seconds? help? :)

Khris

The default game speed is 40, i.e. one frame lasts 1/40 seconds.
A total delay of 5 causes the frame to get displayed 5*1/40 = 5/40 = 1/8 seconds.

SpacePaw

Thank you! Now back to working with gif encoding *mumbles some evil words*

SMF spam blocked by CleanTalk