Adding new animation threads.
by Joshua "The Power Nap" Taylor · in Torque Game Engine · 07/29/2002 (4:43 pm) · 1 replies
In my project Swordplay is one of the primary features. To accomplish this all of the swordplay animations must blend with the running.
One could accomplish this by using the Recoil thread. While that will get results up to a point, my project needs more control over the threads.
From taking a day or so to review how and where the recoil thread triggered/updated, this is what I've come up with.
Animations are loaded into the player via -=Player::onNewDataBlock=-
Animations are updated (recoil thread before animation tree) in -=Player::updateAnimation=-
in Player::updateMove, the triggers 0 and 1 are checked, if true they call -=ShapeBase::setImageTriggerState=-. Passing it the slot and trigger.
in ShapeBase::setImageTriggerState, the state is set to true or false accordingly and -=ShapeBase::updateImageState=- is called.
Depending on the animation, and values set in the datablock, a timescale is figured and passed to -=ShapeBase::setImageState=-
Here in ShapeBase::setImageState is where the ::onFire script is called from the image datablock and the thread timescales are set.
Adding script control over what happens on trigger 0 and 1 isn't hard. Having control over the recoil thread, or a thread like it is a bit harder.
My goal is for a player to swing his/her melee weapon and upon hitting something, either continue with the swing or to simulate rebound by stepping the animation back one or two keyframes. I would like all of this to be controlled by scripts. I'm looking to have combo strings similar to a fighter. Using the recoil thread just wouldn't cut it.
The purpose of this post is
1) find anyone who would like to help on this
2) find out if the info I listed above is correct
3) get any technical insight on the animation system
-Josh
One could accomplish this by using the Recoil thread. While that will get results up to a point, my project needs more control over the threads.
From taking a day or so to review how and where the recoil thread triggered/updated, this is what I've come up with.
Animations are loaded into the player via -=Player::onNewDataBlock=-
Animations are updated (recoil thread before animation tree) in -=Player::updateAnimation=-
in Player::updateMove, the triggers 0 and 1 are checked, if true they call -=ShapeBase::setImageTriggerState=-. Passing it the slot and trigger.
in ShapeBase::setImageTriggerState, the state is set to true or false accordingly and -=ShapeBase::updateImageState=- is called.
Depending on the animation, and values set in the datablock, a timescale is figured and passed to -=ShapeBase::setImageState=-
Here in ShapeBase::setImageState is where the ::onFire script is called from the image datablock and the thread timescales are set.
Adding script control over what happens on trigger 0 and 1 isn't hard. Having control over the recoil thread, or a thread like it is a bit harder.
My goal is for a player to swing his/her melee weapon and upon hitting something, either continue with the swing or to simulate rebound by stepping the animation back one or two keyframes. I would like all of this to be controlled by scripts. I'm looking to have combo strings similar to a fighter. Using the recoil thread just wouldn't cut it.
The purpose of this post is
1) find anyone who would like to help on this
2) find out if the info I listed above is correct
3) get any technical insight on the animation system
-Josh
Torque Owner Josh Albrecht
I simply reverse the direction that the current thread is playing. There is a boolean variable called forward for the animation, just flip the value, and make sure the correct information is sent in the pack and unpack update functions.
I created a second thread for animation for attacks on my player, so that he could say run and slash at the same time. In retrospect, I didnt actually need to create the second thread, I could have used the shapebase ones, but it worked out nicely.
Hope that helps. :)