Game Development Community

Melee Animation Speed

by James Laker (BurNinG) · in Torque Game Engine · 02/06/2005 (11:24 pm) · 3 replies

Please try and stay with me as this is an very important question for me.

What I'm doing:
I'm implementing a Combo System for the Melee resource (By Josh taken from RealmWars).

My Problem
So far everything is working fine except that the speeds of
the animations can't be changed.

What I know
The reason for the Speed not to be changed is because
void Player::startPlayOnce(F32 timeScale) is passed 1.0
in the function player:unpack (Can't remember the exact name)... but it's in
player.cc around line 3500.

In the function bool Player::setArmThreadPlayOnce(const char* sequence)
there is another call to startPlayOnce. Changing this has no effect on the speed.

My Questions
1) Why doesn't the timeScale have any effect in setArmThreadPlayOnce, but do in that player::unpack area of the code?

2) Would the correct way of doing this be to pass the TimeScale from script to a variable in code? Is this the best way? Can you give me any other ideas?

3) When I put a Con::printf("Attempting to play animation") in the setArmThreadPlayOnce function... it displayes that message TWICE for every attack. I don't ge it?

Thanx in advance People!

#1
02/07/2005 (3:53 am)
Hi Burning.

Regarding Q1:
This is simply, because Torque is designed as a client/server system.

When you call setArmThreadPlayOnce() in your script, it is actually called on the server object of the player.
The animation you see, is what the client object is playing, so whatever you pass to startPlayOnce() of the server object is not what the client uses and not what you are see.
unpack() is called on your client object whenever, it receives updates from the server e.g. changes to the played animation.
Since the current implementation calls startPlayOnce(1.0) in unpack() this is what you see on the client.

So: Currently the animation speed of the serverside is overruled by the fixed value 1.0 on the client side (in unpack).

Regarding Q2:
1) You can extend Player::setArmThreadPlayOnce() to take an additional argument for the playback speed.
2) Then you need to define either a new member variable for the armthread speed on your player, or you can extend the ActionAnimation structure, to store this playback speed along the other animation params.
3) Next you have to modify your players network code (packUpdate() and unpackUpdate()) to send and receive the playback speed over the net.
(Either your new variable of the player of the one of the ActionAnimation structure)
4) Last point is to modify the unpackUpdate() method, to use the value of your newly introduced (and networked) playback speed variable, instead of the fixed value of 1.0

Should not be hard to do, if you go for it step by step.

Regarding Q3:
The function get's called client and server side that's because you see it twice. But remember that you SEE only what the client is playing.

If you have problems, post up here and I try to help.
I heavily modified the ArmThread stuff for the current RealmWars version, it's not so hard.

-- Markus
#2
02/07/2005 (4:33 am)
Aha... that makes sense... Your answer 2 question 2 was what i thought i should do... Thanx mon!
#3
06/28/2006 (9:07 pm)
To Markus Nuebel:
Your answer show that you are very good at TGE and Torque script.
I am a new bee. It is very nice to attach a sample.