Game Development Community

Walking and Running

by Brodycat · in Torque Game Engine · 08/16/2005 (7:49 am) · 5 replies

I am trying to get my character to walk at normal movement speed and run when a button is held down. In starter.fps/client/scripts/default.bind.cs, I added the following code:

function dash(%val)
{
if (%val)
$movementSpeed = 2 * %speed;
}


And then farther below...


moveMap.bind( keyboard, a, dash );

Nothing seems to be happening when I press and hold the a button while walking. Is there more I need to do, or is my coding wrong?

#1
08/16/2005 (11:46 am)
A couple of things - you're never setting $movementSpeed back to a reasonable value, you're setting it to 2 times %speed, which is a local variable you never set a value to, so you're probably setting $movementSpeed to zero, and also, the code is designed to prevent cheating so you probably have to send the dash as a flag to the server so it can properly multiply the movement speed of the player; the values sent from the client are just scalar "go in this direction" values, not actual movement speeds.
#2
08/16/2005 (12:34 pm)
Don't %val's only work with moveMap.bindCmd ?
#3
08/16/2005 (1:17 pm)
Ben --> Perhaps I could write dash as a trigger event, in order to revert speed to normal after letting go of the button? Or is sending a boolean to ther server for both press and release of the button preferable?

Oh, and thanks!
#4
08/16/2005 (1:35 pm)
Tying dash functionality to a trigger would be a great solution.
#5
08/16/2005 (9:44 pm)
On a related note, I tried to trace the path of the code as the player takes a jump. I can't seem to find what is called when a jump is made, so I can't really mimic it for my run trigger! In starter.fps/client/scripts/default.bind.cs I find the trigger declarations and bindings, and in starter.fps/server/scripts/player.cs I find the parameters for the jump, such as height, as well as the top-level trigger function. But I can't find the jump ballstics or anything! I'd like to see the physics code so I can base my run trigger on it. What am I missing?