Page 1 of 1

Scaling the speed of animations

Posted: 01 Jan 2016, 01:19
by Boothand
Does anyone know how, if possible, to scale the speed of animations in the gamecode? I'm interested in scaling the speed of saber swings.

Re: Scaling the speed of animations

Posted: 01 Jan 2016, 15:18
by Tr!Force
Is possible. But im at the beach tight now :lol: i scaled the blue swing in bg_animate when 1.02 mode is active and reverted back the speed when 1.04 mode is active (with a cvar). But i think u need clientside to get rid of the little lag when animate ... Or play with pmove_fixed in a way to get work properly.

Re: Scaling the speed of animations

Posted: 01 Jan 2016, 17:32
by Boothand
I'm already compiling the clientside for a lot of the things I've changed, so that won't be a problem. Have fiddled around in bg_panimate.c, but have only found ways to mess up animations rather than slow them down so far.

Re: Scaling the speed of animations

Posted: 02 Jan 2016, 02:13
by Boothand
OK!!!!!! I think I've got it. The only way (or the way), seems to be to change animation.cfg in models/players/_humanoid :D :mrgreen:

Still untested on connecting players.

Re: Scaling the speed of animations

Posted: 02 Jan 2016, 03:56
by Tr!Force
Boothand wrote:OK!!!!!! I think I've got it. The only way (or the way), seems to be to change animation.cfg in models/players/_humanoid :D :mrgreen:

Still untested on connecting players.
Yes that is another way. But not the only... The cfg is only a bunch of "instructions" sent to the client and the client code "translate" these info.

I still preffer to do that via server code, because u can have a total control over that. I will back sunday to my home, i can show u how i manage the animation speed on my gameplay changer.

Re: Scaling the speed of animations

Posted: 02 Jan 2016, 16:14
by Daggolin
Why does your gameplay changer even change animation speed? o.O

Re: Scaling the speed of animations

Posted: 03 Jan 2016, 00:37
by Tr!Force
Daggolin wrote:Why does your gameplay changer even change animation speed? o.O
Blue stance spinning attack (left or right) is slower on 1.02 instead 1.03 & 1.04, i know is not the proper way to do, but i did the change of the animation speed before ravensoft release... So it works fine

Re: Scaling the speed of animations

Posted: 03 Jan 2016, 10:37
by Boothand
Still interested to know where you do it in the code :D

Re: Scaling the speed of animations

Posted: 03 Jan 2016, 13:51
by Tr!Force
Boothand wrote:Still interested to know where you do it in the code :D
Im returning to my home right now :D i was on the beach, is summer here :lol:

Re: Scaling the speed of animations

Posted: 03 Jan 2016, 22:00
by Daggolin
Tr!Force wrote:
Daggolin wrote:Why does your gameplay changer even change animation speed? o.O
Blue stance spinning attack (left or right) is slower on 1.02 instead 1.03 & 1.04, i know is not the proper way to do, but i did the change of the animation speed before ravensoft release... So it works fine
I don't remember any changes regarding animation-speed in the jk2 code. :/

Re: Scaling the speed of animations

Posted: 03 Jan 2016, 22:52
by Tr!Force
Daggolin wrote:
Tr!Force wrote:
Daggolin wrote:Why does your gameplay changer even change animation speed? o.O
Blue stance spinning attack (left or right) is slower on 1.02 instead 1.03 & 1.04, i know is not the proper way to do, but i did the change of the animation speed before ravensoft release... So it works fine
I don't remember any changes regarding animation-speed in the jk2 code. :/
i did via code because in those days i did not have the code, u just found a way to do that. i dont know how works now (in the real source code), but that animation is slower on 1.02, just try :)

Re: Scaling the speed of animations

Posted: 04 Jan 2016, 05:00
by Tr!Force
i just back, i used BG_SaberStartTransAnim function to manage the speed of animations :D

Re: Scaling the speed of animations

Posted: 04 Jan 2016, 06:31
by Boothand
Isn't that only the speed between chain animations? I was able to change that, but not the fps of each individual animation. Doing it via animation.cfg is great though. No recompile needed etc.

Re: Scaling the speed of animations

Posted: 04 Jan 2016, 11:42
by Tr!Force
Boothand wrote:Isn't that only the speed between chain animations? I was able to change that, but not the fps of each individual animation. Doing it via animation.cfg is great though. No recompile needed etc.
Ya i know, is just a way to do, i have my own animation.cfg too :p but in my case i was used with a cvar to change the speed everytime i want, the code one works over the current speed, so u cam increase or decrease

Re: Scaling the speed of animations

Posted: 04 Jan 2016, 11:51
by Boothand
But not the fps of an animation, right? I don't think there's anything in the code that lets an actual animation go slower, let alone a specific one?

Re: Scaling the speed of animations

Posted: 04 Jan 2016, 12:29
by Tr!Force
Boothand wrote:But not the fps of an animation, right? I don't think there's anything in the code that lets an actual animation go slower, let alone a specific one?
is not fps management, with that function the animation goes slower. for example i did this:

Code: Select all

#ifdef CLIENTCOMPILE
	g_gameplay.integer=cgs.g_gameplay;
#endif
    
if ( ( (anim&~ANIM_TOGGLEBIT) >= BOTH_T1_BR__R &&
	(anim&~ANIM_TOGGLEBIT) <= BOTH_T1_BL_TL ) ||
	( (anim&~ANIM_TOGGLEBIT) >= BOTH_T2_BR__R &&
	(anim&~ANIM_TOGGLEBIT) <= BOTH_T2_BL_TL ) ||
	( (anim&~ANIM_TOGGLEBIT) >= BOTH_T3_BR__R &&
	(anim&~ANIM_TOGGLEBIT) <= BOTH_T3_BL_TL ) )
	{
    
 	if ( saberAnimLevel == FORCE_LEVEL_1 )
	{
        	if (g_gameplay.integer == 0)
        	{
           		*animSpeed *= 1.0; //1.0 = v1.02
        	}
		else
		{
			*animSpeed *= 1.5; //1.5 = v1.03 and v1.04
		}
 	} 
	
	[...]

Re: Scaling the speed of animations

Posted: 04 Jan 2016, 14:43
by Boothand
Hmm, was sure I had tried to change that variable, in lots of places. I'll check it out later.

Re: Scaling the speed of animations

Posted: 07 Jan 2016, 14:43
by Boothand
Making those numbers low only makes the animations stop and wait before going on. In any case, I use animation.cfg for the actual speeds, so won't be an issue.
Also, I just noticed by the way in my jk2mp sourcecode, that 1.5 is 1.02's default, regarding the above example.

Re: Scaling the speed of animations

Posted: 07 Jan 2016, 16:04
by Tr!Force
Boothand wrote:Making those numbers low only makes the animations stop and wait before going on. In any case, I use animation.cfg for the actual speeds, so won't be an issue.
Also, I just noticed by the way in my jk2mp sourcecode, that 1.5 is 1.02's default, regarding the above example.
Yes, is 1.5 in every version, but that 1.5 is applied to the base speed in animation.cfg, so, 1.5 applied into 1.02 is ok, 1.5 applied into 1.03 or 1.04 is different, is why i reduced only to 1.0, because i used the 1.04 source code in these days... animSpeed value is not a definition of the speed, is just how much i want increase or decrease the actual speed of an animation.

about the stop & wait problem, that is because u need send that info from the server to the client, u need a conection (if u want to get it customizable by a cvar), is why i used:

Code: Select all

#ifdef CLIENTCOMPILE
   g_gameplay.integer=cgs.g_gameplay;
#endif
is how i get everything about movements recognized by the clientside. (and to get rid the "stop & wait" problem)

look this example, i did it only via code (the code i posted above):



anyways, if u dont want to change it everytime, just use animation.cfg :D

Re: Scaling the speed of animations

Posted: 07 Jan 2016, 17:13
by Boothand
As I mentioned earlier though (and as your video demonstrates), it only changes the speed of the transition animations, not the swings themselves, so I don't see an alternative to using animation.cfg.

As for the client knowing what's going on when it stops and waits, this is a BG function, and compiled into the cgame (which I'm using) as well, so I don't think it's that. Probably more to do with the math going on outside when animSpeedScale returns from the TransAnim function.

Code: Select all

BG_SaberStartTransAnim(self->client->ps.fd.saberAnimLevel, f, &animSpeedScale);

		animSpeed = 50.0f / bgGlobalAnimations[f].frameLerp;
		animSpeedScale = (animSpeed *= animSpeedScale);
Anyway, not important unless people google this :D


However, if you can think of a way to change the blend time or speed between certain animations (specific animations), then that would still be interesting. I have buttons for triggering block animations, but they are only a keyframe that it blends to over time, so it can't be solved by changing animation speed in animation.cfg - but what sets the time they use to get in position? If anyone has a clue, do tell. The animation tables have a blendTime associated but changing them doesn't have an effect there, so I assume it gets overridden somehow. Somewhere. Somewhere obscure.

Re: Scaling the speed of animations

Posted: 07 Jan 2016, 17:19
by Tr!Force
nice, i thought it worked differently, i did these work a long time ago, so did not remember how it worked :lol: thanks for the clarification
Boothand wrote:I have buttons for triggering block animations, but they are only a keyframe that it blends to over time - but what time is that? If anyone has a clue, do tell. The animation tables have a blendTime associated but changing them don't have an effect there, so I assume it gets overridden somehow. Somewhere. Somewhere obscure.
i have the same question, ive played a little with ModView to look for a clue to search it in somewhere in the code but i didnt find anything...

maybe is in some obscure place. :|