Game Development Community

Sprint code - changing the engine. is this how i want to proceed

by James Thomas · in Technical Issues · 12/30/2008 (2:16 pm) · 4 replies

The problem:

I want to allow the PC in my game to activate a 'sprint', where he will then move 1.5 (or some factor) faster for ten seconds.

The datablock for players sets the runforce and various max speeds.

my solution (so far):
i have added a F32 sprintFactor to the source. i also need to have a bool variable for each player called isSprinting, and have a function to turn it on or off. i will then find the code for running, jumping, etc, and change them to multiply the final vector by 1.5

next i will in script add controls for activating sprint. a client keypress will call the server to activate sprint for their character and schedule it to be turned off ten seconds later.

my questions:

is this a smart way to do this or am i missing something obvious?

#2
12/30/2008 (3:13 pm)
Yeah, you're on the right track. Definitely check out that second resource.
#3
12/30/2008 (9:41 pm)
You guys are awesome, thanks.

one more question:

How do i use code in the engine from the script?
i have:

function serverCmdSprint(%client)
{
echo("entered serverCmdSprint");
if (!%client.player.IsSprinting())
{
%client.player.setSprinting(true);
%client.player.schedule(10000, "setSprinting", false);
}
}

but when it runs i get errors in the console:

entered serverCmdSprint
FlyingMouthProductions/server/scripts/commands.cs (21): Unknown command IsSprinting.
Object (1548) Player -> ShapeBase -> GameBase -> SceneObject -> NetObject -> SimObject
FlyingMouthProductions/server/scripts/commands.cs (23): Unknown command setSprinting.
Object (1548) Player -> ShapeBase -> GameBase -> SceneObject -> NetObject -> SimObject

IsSprinting and setSprinting are defined in player.h and player.cc as public. what am i doing wrong?

ps after i get this working ill make it a resource. i think it is a little simpler than the previous ones.
#4
12/31/2008 (7:44 pm)
Never mind, i got sprint working great. just needed to add a console method.

thanks for the help guys. since their is already a good resource (2nd link) ill make the next task i do a resource:

coming soon: lock on targeting.

sweet, and happy new years.