Move : Walk/Run - advice needed
by elvince · in Torque 3D Professional · 03/22/2010 (9:30 am) · 4 replies
Hi,
I want to implement a walk run function where running is draining energy.
In the current source code, we already have energy draining on run, we have the setspeed to go slower/faster.
But the speed is set on client side as the speed move is depending of the databablock max speed * $mvForwardAction. This information is sent by the client and based upon $movementSpeed global variable on client.
Can we trust the client on this? I mean, as the client is sending the information "$mvForwardAction" and we are basing on the movement on this value, is it safe?
In current implement, it is, as we are using the max value of the datablock as the "common" move speed.
So I think we need to implement it on server side and use it to modify the speed value in Player.cpp.
2nd set of question is for the walk sequence: Where does the like between the run sequence & moveforward is made? I mean if I want to play a walk animation if my speed is 50% and run animation when it's 100% where can I found this?
Any other approach I should consider? Any feedback on this?
Thanks,
I want to implement a walk run function where running is draining energy.
In the current source code, we already have energy draining on run, we have the setspeed to go slower/faster.
But the speed is set on client side as the speed move is depending of the databablock max speed * $mvForwardAction. This information is sent by the client and based upon $movementSpeed global variable on client.
Can we trust the client on this? I mean, as the client is sending the information "$mvForwardAction" and we are basing on the movement on this value, is it safe?
In current implement, it is, as we are using the max value of the datablock as the "common" move speed.
So I think we need to implement it on server side and use it to modify the speed value in Player.cpp.
2nd set of question is for the walk sequence: Where does the like between the run sequence & moveforward is made? I mean if I want to play a walk animation if my speed is 50% and run animation when it's 100% where can I found this?
Any other approach I should consider? Any feedback on this?
Thanks,
About the author
Recent Threads
#2
03/22/2010 (11:08 am)
Thanks, I will look into the thread.
#3
Now if we have a pointer (*move) to the current move,
then the moveVec vector is calculated using move->x and move->y
This is how the XY movement direction is produced.
The Z direction of the movement is produced in a different way,various forces are taken into account instead...like gravity,gravitymod,resistance,drag,jet...
The rest stuff is not important - it deals with physics mostly.
Animation is handled in pickActionAnimation()
Player's velocity is translated in object space,because this simplifies the math.
If the player is on the ground (this deals with a contact timer),if we have an acceleration (this deals with object space velocity) and if the animation direction vector is almost parallel to this velocity (deals with a dot product),then run animation is picked.
This is basically how the movement code is organized.
03/23/2010 (5:39 am)
$mvForwardAction (respectively mForwardAction in moveManager) is used to compute curMove.y in moveListcurMove.x = MoveManager::mRightAction - MoveManager::mLeftAction + MoveManager::mXAxis_L; curMove.y = MoveManager::mForwardAction - MoveManager::mBackwardAction + MoveManager::mYAxis_L;
Now if we have a pointer (*move) to the current move,
then the moveVec vector is calculated using move->x and move->y
zRot.getColumn(0,&moveVec); moveVec *= move->x; VectorF tv; zRot.getColumn(1,&tv); moveVec += tv * move->y
This is how the XY movement direction is produced.
The Z direction of the movement is produced in a different way,various forces are taken into account instead...like gravity,gravitymod,resistance,drag,jet...
The rest stuff is not important - it deals with physics mostly.
Animation is handled in pickActionAnimation()
Player's velocity is translated in object space,because this simplifies the math.
If the player is on the ground (this deals with a contact timer),if we have an acceleration (this deals with object space velocity) and if the animation direction vector is almost parallel to this velocity (deals with a dot product),then run animation is picked.
This is basically how the movement code is organized.
#4
03/24/2010 (2:01 am)
Thanks Ivan, this is really useful.
Associate Steve Acaster
[YorkshireRifles.com]
For seperate walk you'd have to put them in code with the rest of the player move animations ... not sure how easy that'd be, whether you could just copy the standard run stuff and change it to walk and reduce the speed ...
anyhow, that linky, have a look see if you can use it for the same sort of thing.