Single Cycle / Looping Animation
by QuangKim · in Torque Game Engine · 12/29/2005 (5:52 am) · 12 replies
I would like to know how to specify LOOPING or SINGLE cycle of animation in setActionThread, could some one direct me to a sample or help me with this.
About the author
#2
1. Create a function*N in the player.cs script, that plays the certain animation on a Thread.
2. Create a function serverCmd*N in the commands.cs script that activates the event.
3. Create a moveMap.bindCmd*N in default.binds.cs script.
4. Delete any previous configs.dso scripts.
I'm not entirely sure about step 4., but I'm pretty sure those files get written after the engine fires, as I notice these files usually end up as mystery files in a fresh CVS update and aren't in the ignored list...;).
...take a look at how the player fires off the celebrate animations and the suicide animations....they have keybindings setup already and seemingly would be a good place to mod over a testing...
12/29/2005 (8:57 am)
@NR: I'm not entirely sure how to tie this into the mounting functionality; but I think what you want to do, would be to take this approach:1. Create a function*N in the player.cs script, that plays the certain animation on a Thread.
2. Create a function serverCmd*N in the commands.cs script that activates the event.
3. Create a moveMap.bindCmd*N in default.binds.cs script.
4. Delete any previous configs.dso scripts.
I'm not entirely sure about step 4., but I'm pretty sure those files get written after the engine fires, as I notice these files usually end up as mystery files in a fresh CVS update and aren't in the ignored list...;).
...take a look at how the player fires off the celebrate animations and the suicide animations....they have keybindings setup already and seemingly would be a good place to mod over a testing...
#3
As Rex mentioned, you should trace through the "wave" and "salute" implementations from default.binds.cs all the way through to the server side code--it's an excellent exercise in seeing how not only animations can be called from script, but how commandToServer/commandToClient work as well.
@Rex: The files that get created by the engine at runtime are the config.cs/config.cs.dso files. Whenever you change default.binds.cs, you should always delete your config.cs/config.cs.dso files so that your changes "take". This only needs to be done the first run of your executable after the .binds.cs changes, it will "take" after that.
12/29/2005 (9:13 am)
To the original poster: looping or single cycle is part of the animation itself, not how the animation is called.As Rex mentioned, you should trace through the "wave" and "salute" implementations from default.binds.cs all the way through to the server side code--it's an excellent exercise in seeing how not only animations can be called from script, but how commandToServer/commandToClient work as well.
@Rex: The files that get created by the engine at runtime are the config.cs/config.cs.dso files. Whenever you change default.binds.cs, you should always delete your config.cs/config.cs.dso files so that your changes "take". This only needs to be done the first run of your executable after the .binds.cs changes, it will "take" after that.
#4
12/29/2005 (9:43 am)
Thanks, Stephen, it's config's...my bad.
#5
but will it be fairly easy for me to construct an idle 'animation' by playing small idle animations in random order ?
eg i'm hoping for something like a callback when an (idle) animation finishes so that i can launch the next one.
12/29/2005 (9:52 am)
Somewhat OT,but will it be fairly easy for me to construct an idle 'animation' by playing small idle animations in random order ?
eg i'm hoping for something like a callback when an (idle) animation finishes so that i can launch the next one.
#6
If you want to have multiple animations for a single phase like "idle", you'll probably want to modify pickActionAnimation() to allow for random idle animations. You'll also of course need to have a naming convention for them similar to the deathX animations, or something similar to keep track.
12/29/2005 (10:15 am)
AnimationDone() is a stock callback for any single-shot animation for objects of class Player, but not for cycling ones (they don't ever actually end obviously).If you want to have multiple animations for a single phase like "idle", you'll probably want to modify pickActionAnimation() to allow for random idle animations. You'll also of course need to have a naming convention for them similar to the deathX animations, or something similar to keep track.
#7
12/29/2005 (10:20 am)
Sounds good, thanks stephen.
#8
12/29/2005 (8:15 pm)
What i want is to specify that I want one animation to be played now and then blend into a cyclic idle animation, sort of like a player waiting to hit a ball, hits a ball and returns to wait. I dont seem to be able to stop them from looping.
#9
You probably (I'm not an artist, so this is a rough guess) want to set up your animations as such:
"Batting Stance": cycling idle-style animation, similar in all ways to the "root" pose.
"Swinging": non-cyclic animation.
When the batter is up to the plate, they would have pickActionAnimation() "aware" of the "ready to bat" type of state, and play the appropriate BattingStanceIdle animation. When the player hits the "swing" key, then they should set the state to "swinging", play the swing animation (once), and in the animationDone() callback set the state to whatever makes sense next...possibly even just "not swinging" or something similar, if the player has to run on their own to the base.
That's just a rough outline, but I do suggest you study pickActionAnimation(), combined with the script function serverCmdPlayCel (in /starter.fps/server/scripts.commands.cs), and finally Player::playCelAnimation() in /server/scripts/player.cs.
12/29/2005 (8:59 pm)
@QuangKim:You probably (I'm not an artist, so this is a rough guess) want to set up your animations as such:
"Batting Stance": cycling idle-style animation, similar in all ways to the "root" pose.
"Swinging": non-cyclic animation.
When the batter is up to the plate, they would have pickActionAnimation() "aware" of the "ready to bat" type of state, and play the appropriate BattingStanceIdle animation. When the player hits the "swing" key, then they should set the state to "swinging", play the swing animation (once), and in the animationDone() callback set the state to whatever makes sense next...possibly even just "not swinging" or something similar, if the player has to run on their own to the base.
That's just a rough outline, but I do suggest you study pickActionAnimation(), combined with the script function serverCmdPlayCel (in /starter.fps/server/scripts.commands.cs), and finally Player::playCelAnimation() in /server/scripts/player.cs.
#10
12/29/2005 (11:40 pm)
@QuangKim, sorry who are you??
#11
12/30/2005 (12:19 am)
Umm, you! At least according to your login's display name!
#12
12/30/2005 (12:25 am)
@Stephen sorry, I think someone hasmy password.
Torque Owner N R Bharathae
What I'm having trouble with myself is finding the script code used to call the animations in the first place. I can set looping animations but have yet to figure out how to set single run animations and have them bound to a key. I'd like to keybind some animations like opening a car door to mount the player model.