Game Development Community

Adjusting player movement speed in realtime

by Donald "DrPsycho" Piret · in Torque Game Engine · 10/04/2001 (6:35 am) · 21 replies

Does anybody know how to change the player speed realtime ingame, for example in a function or in a keybind? Cause it seems to me that as it's part of the datablock there will be some trouble changin it realtime. Has anybody found any way around this yet?
Page «Previous 1 2
#1
10/04/2001 (7:19 am)
It depends what you mean by changing it. if you mean continually changing, then its probably going to take some work. if you mean simply changing state from run to walk, you can just have run/walk speeds in the datablock and swap between.

If you want continually changing speeds, its going to be a problem because its going to mess the prediction up.

Phil.
#2
10/04/2001 (9:23 am)
Ok, well than how could i change from a run/walk state?
#3
10/04/2001 (8:27 pm)
If you look at the camera code, it changes from a slow to a fast speed based on a trigger (bound to the second mouse button I think). You can change speeds and have the prediction work fine for the player as well as long as this change is tied to an input move event. The objects states and prediction code runs off of these input events in conjunction with synchronized state information.

You could use one of the triggers to toggle between a walk/run speed in Player::updateMove(). You'd have to make sure the current state is transmitted to the client as part of the Player::writePacketData() method (which updates the controlling client with current state info.)

(the camera code doesn't use a slow/fast state, just changes speed right off the move trigger)
#4
05/12/2002 (11:03 pm)
So does this mean it would be "difficult" to have a variable speed player?

Say the player has a maxSpeed but as it takes damage its maxSpeed is calculated based on stamina, damage taken, terrain type, position ( crouch, prone )?
#5
05/13/2002 (12:26 am)
I have done both the run/walk transition and the adjustable player movement speed in Trakers

If you like I can send the appropriate code.
If more than one person is interested I can post it as a resource easily enough.

It requires a fairly substantial change to the way that the player movement is calculated. Instead of getting the runspeed and run force from the player datablock it actually gets it from the player itself (which is initiated from the datablock initially)

In this way it allows every player in the game to run at different speeds.

I took this a bit further in my game to make players slow down when they were cattying certain amounts of weight, but that is irrelevant here.

The point is, it can be done :)
#6
05/13/2002 (12:37 am)
Well, a resource would be great! I guess there are lots of Torquers interested...
#7
05/13/2002 (3:29 am)
ok.
Ill write it up tonight and submit it.
#8
05/13/2002 (8:43 am)
I would love to see what you did.

I plan on taking this "a bit farther also", I am also planning on having an encumberance factor to the player model.

as I am working on the requirments documentation and use cases for what could best be described as a "Tactical First Person Shooter with Role Playing Game aspects"
Imagine playing Jagged Alliance 2 / Fallout from First Person, with Multi-players, both Co-op and Opposing Teams.

I am _planning_ on having a list of attributes that the player starts out with that apply bonus/penality modifiers as percentages to almost every action the player can attempt.
This would make for a more consistent "world" for class based games and for "realistic" games.

I want to be able to do this with Weapons and Vehicles.
Affect the "performance" characteristics during the game in real time. I assumed I would have to modified the Player in C++ but in the 2 days I have had the source I have not had time to _REALLY_ dig thru it.

Just for the record I am 100% willing to help in contributing any tutorials or "documentation" for the community, once I get up to speed with Torque.

I learned the SoF SDK in a week, this will be a little more of a learning curve.
#9
05/13/2002 (9:08 am)
i have a run/walk resource too, you toggle the modes with a key (while u press key it runs, when u let go it walks)
the walk and run speeds are configured in the player datablock
#10
05/13/2002 (9:33 am)
configuring run/walk in the datablock will not work for dynamic speed calculations. The datablock is static. I wan the datablock to define a BASE SPEED for each movement type, then adjust +/- it based on encumberance, damage and other things that would affect a player/vehicle movement capabilities.
#11
05/13/2002 (9:59 am)
oh, well what my code does is basically the transition from running and walking... if u want other speed transitions... like if hit lower speed by 2.. that's easily doable in the engine.. very easy
#12
08/13/2004 (10:05 am)
I'm interested in variable movement speeds too!
#13
08/14/2004 (8:19 am)
There was a resource for this: search the resources for run maybe?
#14
11/08/2004 (5:48 pm)
How do you swap the animations from run to walk? Simply slowing down the character move speed will have the animation running in place and skidding across the floor no?
#15
11/08/2004 (8:49 pm)
No, it won't, because movement animations SHOULD be done using ground transforms, so that they always synch with the actual motion.

Of course, having a special walk anim that you switch to will look nicer than a very slow run anim!
#16
11/09/2004 (5:58 am)
In the game I'm working on, I adjust the players's speed and the guy's movements seem fairly ok.. mind you, I'm using the orc and he may have a special "walk" animation. He DOES skid sideways, but it uses the appropriate animations when he does (looks cool) and side-skidding is what I want.
#17
01/14/2005 (12:58 pm)
It's not difficult.. if it's not solved, lemme know, my game has it
#18
03/17/2005 (6:43 am)
A question @ Phil/Tim: is this naming convention "walk" tied to the playerClass move events as well[like run, back, etc]? Meaning, to acheive a walk state with the default build; the player only needs the sequence itself and the edit to the dataBlock? Or is there a bit more to it? a function/method added, and a keybind.
#19
03/17/2005 (9:52 am)
Sure Juan, I'd be happy to. You can reach me on IM or through here.

All I did to adjust speed realitime was to short-circuit the player's actual control code in prefs.cs I believe, so that when teh "w" key is pressed.. if the player is damaged he only gets 0.5 added to his speed as opposed to 1.0. I'm told this is wide open to cheating by my torque buddies, but it serves my purposes for right now. I'll just spot the code for you:

Ya, in default.bind.cs:

I defined:
$movementSpeed = 1; // m/s
$woundedSpeed = 0.5; // m/s

function moveforward(%val)
{
   $mvForwardAction = %val * $movementSpeed;
   if( LocalClientConnection.player.isWounded() ) {     //this is not very efficient, is it   
           //echo("%client=" @ %client );
           $mvForwardAction = %val * $woundedSpeed;
           echo("moving at half-speed");
   }//endif
   //%this.setActionThread("back");
}
#20
05/09/2005 (3:33 pm)
IM is short for Instant Messenger, my coordinates are:

loopywolf@hotmail.com on MSN,
whiteloopywolf on AIM
Page «Previous 1 2