Specify animation starting frame
by John Pritchett · in Torque Game Builder · 07/27/2005 (9:08 am) · 4 replies
As always, there may be some super secret way to do this that I'm not seeing ;) But if there isn't, this is an important and easy to add feature for animated sprites. The engine currently supports random starting points, so it should be easy to specify a particular starting frame. Maybe a new field, animatedDatablock.startingFrame or whatever.
This is useful in case you have various animations that are associated so that when you switch from one to another, the animation could be made continuous by specifying the start frame of the new animation as the current frame of the last animation plus 1.
In my case, I'm using 4 different animations for the 4 directions for objects that are mounted to another object. Hopefully this won't be necessary in the future once you can rotate an object independent of its mount even when it's locked to the rotation of the mount point. But for now, I have this issue of the animation jumping every time the actor turns a corner on the screen.
Most of the problems I've run into with the engine could be solved by modifying the engine, I know, but then that would only help me.
Anyway, keep up the great work. I can't say enough positive things about T2D. Hopefully I'll have a game to present at GG soon. It's coming along.
This is useful in case you have various animations that are associated so that when you switch from one to another, the animation could be made continuous by specifying the start frame of the new animation as the current frame of the last animation plus 1.
In my case, I'm using 4 different animations for the 4 directions for objects that are mounted to another object. Hopefully this won't be necessary in the future once you can rotate an object independent of its mount even when it's locked to the rotation of the mount point. But for now, I have this issue of the animation jumping every time the actor turns a corner on the screen.
Most of the problems I've run into with the engine could be solved by modifying the engine, I know, but then that would only help me.
Anyway, keep up the great work. I can't say enough positive things about T2D. Hopefully I'll have a game to present at GG soon. It's coming along.
About the author
Indie developer since 1994, games include TradeWars 2002 (named 10th best PC game of all time by PCWorld magazine), TW: Dark Millennium/Exarch/Dungeon Runners, and Rocketbowl 360. Have worked for Martech Software, 21-6, EIS and Black Squirrel Studios.
#2
So if I was in frame x of the running animation, and the player presses the shoot key, then I would want to play the running-with-gun-out animation at x (or x+1).
I realize that I can get around this problem in a variety of ways, one of which is to split the sprite into different "limbs" and just have a separate animation for his right hand without messing up the other limbs' animation cycles ... but really a simple %sprite.SetAnimationFrame() would work, and be easier to manage. :)
Keep up the great work guys!
-Jacob
09/07/2005 (1:10 pm)
Hate to drag up an old thread, but I've discovered that this will be very useful for me as well. I have 2 animations for my main character: one running, and one running with his gun pointed out. I want to be able to transition from one to the other while keeping it transparent to the viewer.So if I was in frame x of the running animation, and the player presses the shoot key, then I would want to play the running-with-gun-out animation at x (or x+1).
I realize that I can get around this problem in a variety of ways, one of which is to split the sprite into different "limbs" and just have a separate animation for his right hand without messing up the other limbs' animation cycles ... but really a simple %sprite.SetAnimationFrame() would work, and be easier to manage. :)
Keep up the great work guys!
-Jacob
#3
Actually, you don't want to do that. What you want to do is transfer the time between the two animations. After all, each frame takes up a particular quantity of time. If it's in the middle of that time frame when you switch animations, you need to start the other one in the middle of that timeframe. Otherwise, the current frame's leg position will appear to "hold" for longer than its normal time.
Effectively, you don't care about frames in one vs. the other. What you care about is the "normalized time". Normalized time is a timescale range from 0 to 1 of an animation, where 0 is the beginning and 1 is the end. Now, it isn't a true "time" scale because the duration of the animation is ignored (a 2- minute long animation still goes from 0 to 1). Think of normalized time as the progress through an animation.
When you do this kind of animation "transfer", you simply preserve the normalized time when you change animations. It's up to you as to whether these two animations match up in terms of their frames, but if they do, then this would work perfectly.
09/07/2005 (1:49 pm)
Quote:So if I was in frame x of the running animation, and the player presses the shoot key, then I would want to play the running-with-gun-out animation at x (or x+1).
Actually, you don't want to do that. What you want to do is transfer the time between the two animations. After all, each frame takes up a particular quantity of time. If it's in the middle of that time frame when you switch animations, you need to start the other one in the middle of that timeframe. Otherwise, the current frame's leg position will appear to "hold" for longer than its normal time.
Effectively, you don't care about frames in one vs. the other. What you care about is the "normalized time". Normalized time is a timescale range from 0 to 1 of an animation, where 0 is the beginning and 1 is the end. Now, it isn't a true "time" scale because the duration of the animation is ignored (a 2- minute long animation still goes from 0 to 1). Think of normalized time as the progress through an animation.
When you do this kind of animation "transfer", you simply preserve the normalized time when you change animations. It's up to you as to whether these two animations match up in terms of their frames, but if they do, then this would work perfectly.
#4
It would be up to the programmer to make sure the animations synced graphically.
Anyone know of a way of getting at the animation time data (through script) so that I can put together something like this myself? I didn't see anything in the T2D Reference...
-Jacob
09/08/2005 (5:01 pm)
Okay, so I recant my above statement. Smaug is right, there would be noticible pausing. What would really be nice is, as suggested, is to have a SwitchAnimation() or a similarly-named function that woud just swap out the animation and preserve the normalized time, so that if the current animation is currently 0.25 elapsed, then the new animation would play starting with 0.25 of the time elapsed.It would be up to the programmer to make sure the animations synced graphically.
Anyone know of a way of getting at the animation time data (through script) so that I can put together something like this myself? I didn't see anything in the T2D Reference...
-Jacob
Associate Melv May
The animation system will be given plenty of love. The existing one is probably categorised as adequate. It'll still be datablock driven but the internal animation controller will provide much more functionality.
No dates, just a guarantee. ;)
- Melv.