Game Development Community

Rollerblading, ice...

by Ryan Ackley · in Torque Game Engine · 11/22/2002 (2:51 pm) · 8 replies

Anybody know of an easy way to go about implementing these types of things. Basically, the only thing i want to change is the rate you slow down after you release the foward key (to glide on rollerblades). Ive looked at Player::updateMove() and other movement related functions in player.cc and cant find anything related (that function is mad confusing!) Can anyone point out a var or function i should take a look at? Thnanks
Ryan

[edit]
a little side note, i ran a trace on the console, and checked the log. Heres the functions that are called.

Entering (null)::moveforward(1)
Leaving (null)::moveforward - return 1
Entering (null)::moveforward(0)
Leaving (null)::moveforward - return 0

so I searched for moveforward() and found it in default.bind.cs

function moveforward(%val)
{
$mvForwardAction = %val;
}

the engine references mvForwardAction in GameConnectionMoves.cc in the function

bool GameConnection::getNextMove

And then i get lost in that function, not quite sure where it flows to after this. Ideas?
[\edit]

#1
11/22/2002 (3:17 pm)
Have you looked at the vehicle code? I know that when you let off pressing forward in Tribes 2 the vehicles will coast till they stop. Might be of some help to look over those.
#2
11/22/2002 (3:30 pm)
I looked into car.cs, which wasnt helpful, because it looks like there is an enginebrake var, which is used (since vehicles are supposed to keep moving foward), theres no such variable for the player (in either player.cc or .cs) Im still digging, but im running into deadends
Ryan
#3
11/22/2002 (7:19 pm)
Basically you want less friction or drag.

Look for the line:

mVelocity -= mVelocity * mDrag * TickSec;

in player.cc




Hey, just a note. This seems like it should work, but it doesn't.

Where the hell is friction and drag applied to the player!? I've commented out air resistance, removing velocity into the ground, the bouyancy/gravity part, none of it seems to make a difference.
#4
11/22/2002 (9:10 pm)
Ugh, ive been fighting this for a little bit now. At the end of updatemove, i threw this in:
float slowrate = 0.9;
   if(move->y==0 && mVelocity.y>0)
   {
		mVelocity.y = mVelocity.y * slowrate;
   }

But i dont get the desired effect (or any effect... ugh) If i make slowrate above 1 (so i should be gaining speed, instead of slowing when i let go of the forard key) I fly in the Y direction in the world. Its so strange that only making it bigger works. I know im gonna have to apply a rotation and then apply the force in the correct direction, but i cant figure out the calculation to make. Blah. Anyone see my mistake?
ryan
#5
12/15/2002 (2:20 pm)
Has anyone made any progress with this?
#6
05/27/2003 (4:36 pm)
I hope this is still usefull, but i do know this :)

in Player::updateMove find:
VectorF runAcc = pv - (mVelocity + acc); (in the runSurface if)
and change it to:
VectorF runAcc = pv - ((mVelocity * mPow(slowrate,TickSec) + acc);
that should work :)
the mPow is just for neatness, to count it the time it has taken from the last update... just leave it in anyway :) normal math

hope ive helped'
any more questions? feel free to mail me at djmysticje@hotmail.com
#7
05/27/2003 (5:50 pm)
The sad thing was, I thought this was a rant about rollerblading on ice, and I was going to add my $0.02. The sadder thing is, I have been rollerblading when there is ice on the ground. It sucks.
#8
08/15/2004 (7:50 am)
Will that make for less friction on the player?