Game Development Community

Animation Timescaling

by Paul /*Wedge*/ DElia · in General Discussion · 03/20/2004 (1:10 am) · 11 replies

I noticed the melee weapon swing animations have a property called "timescale" but it doesn't do anything as far as I can tell. Was this planned to be used so you could speed up or slow down the animation sequence? I recall it's not supposed to be very hard to do, it just has to happen in the source not in script. Just thought that'd be nice to throw into the next release, since the melee stuff hanldes kina klunky right now. You could have quick weak strikes and hard slow strikes like that too, which would be more interesting I think.

#1
03/20/2004 (10:15 am)
Paul,

You are correct.

Timescale is not connected.

The C++ exposes a script function called: setArmThreadPlayOnce which needs to take that timescale as a parameter and pass it down deepter to the C++ function called: startPlayOnce(), which, stupidly, now hard codes the time scale to 1.0.

Another Torque user, Josh Moore, emailed me just recently with some improvements he had made to the RW melee code. I will make an effort to roll a fix for the problem you mention as well as Josh's improvements into the current RW source. I can't make any promises as to *when* I will do that, but I will make an effort.
#2
03/25/2004 (3:01 pm)
Good to know that those improvments are useful. Timescale is used to calculate if the melee weapon should do damage. It shouldn't be very hard to add a playSpeed variable to pass into setarmthreadonce. I think I'll give a stab at this.

Edit: I can't seem to get the console method for this function to work.

// called on server
bool Player::setArmThreadPlayOnce(const char* sequence, F32 timeScale)
{
   // if we are already playing arm thread...ignore
   .......
   .......
   startPlayOnce(timeScale);
   return true;
}

I'm not sure why this console method isn't working.
ConsoleMethod( Player, setArmThreadPlayOnce, bool, 3, 3, "(string sequenceName, float timeScale)")
{
   return object->setArmThreadPlayOnce(argv[2], argv[3]);
}
#3
03/27/2004 (5:49 pm)
Because the scripting engine only passes things as floats. So you have to convert argv[3] from a string to a float.
#4
03/28/2004 (12:10 pm)
Thanks, but I get compiler errors with this. It give me this error:
game/player.cc:3930: cannot convert 'const char*' to 'float' in initialization

Is there a better way to converet a string to a float value? If the scripting engine only passes things as floats why do I need to convert them(or was that just a typo)?

ConsoleMethod( Player, setArmThreadPlayOnce, bool, 3, 3, "(string sequenceName, float timeScale)")
{
   float timeScale = argv[3];
   return object->setArmThreadPlayOnce(argv[2], timeScale);
}
#5
03/28/2004 (1:23 pm)
DAtof() will do what you want.
#6
03/28/2004 (8:43 pm)
Using that function gives me a undeclared compile error. I think I need to include the file that has this function, but I can't find witch file its in.

game/player.cc:3931: 'DAtof' undeclared (first use this function)

edit: I've tried using it like this, but they obth get the smae error:
float timeScale = float(DAtof(argv[3]));
float timeScale = DAtof(argv[3]);
#7
03/28/2004 (9:09 pm)
Lower case d. dAtof(). forums messed me up.
#8
03/28/2004 (9:49 pm)
Thanks for the quick reply, that did it. Now i'm having trouble getting advancetimeonce to use the timescale variable. I created a simple F32 var to store the timeScale value, but it doesn't seem to work. Even when I hardcoded the value(the new var is only used for the advancetime).

mArmThreadPlayOnce = true;
   mHandAttackPlaying = true;
   mTimeScale = timeScale;

void Player::advancePlayOnceTime(F32 dt, F32 timeScale)
{
   // advance time
   mShapeInstance->advanceTime(dt,mArmAnimation.thread);

   // if we reached end...
   if (mShapeInstance->getPos(mArmAnimation.thread) == timeScale)
   {
      // phdana hth twitch fix ->
      if (!isGhost())
      {
         stopPlayOnce();
         mArmThreadPlayOnce = false;
      }
      // <- phdana hth twitch fix
   }
}
advancePlayOnceTime(dt, mTimeScale);

The animation plays, but stopPlayOnce is never called. Thers no compile errors. It gives the same result if I just have mTimeScale where timescale is in advancetimeonce.
#9
04/02/2004 (12:16 am)
Ok, I got the time scale working somewhat. However, the animations play at the same speed as before, they just stop faster. I'm not sure how to make the animations speed up/slow down. Is there a command to change the play speed of an animation?
#10
04/02/2004 (8:23 am)
If you look at the function, it stops when the thread's position is timeScale. you probably need to multiply dt by timeScale or something similar.
#11
04/02/2004 (12:23 pm)
Its working now, but there its no different then before. Is there a way to speed the animation up? ATM it plays just at the same speed no matter what the timescale is.