Game Development Community

Higher Jump

by ArchonLight · in Torque Game Engine · 09/02/2008 (6:01 am) · 3 replies

I am now trying to implement something that will make my character jump higher when holding down the space button, but obviously I don't want the player to be able to hold it down forever and jump too high so there must be a cap on it.

Can this be solved by simply putting a new function into the default.bind.cs in the client folder?

thank you!!

#1
09/02/2008 (8:32 am)
Don't have actual code for you, but you could go about it this way.

Find the jump code and create a new server script function called chargedjump or somesuch, with variables of the player object, and a charge time.
In it, take the chargetime variable, cap it to a certain amount, then use it to scale up the applied impulse of a jump.

Create a client side function and bind it to your chareged jump key.
On keydown, set a clientside global to the current time. Call it JumpChargeStart or something
On keyup, send a cmdtoserver of chargedjump, passing current time - JumpChargeStart to it.


It's basically the same code tribes used for grenades.
Now you could do it a couple different ways too, but this is quite easy. Though, like tribes, it allows enterprising scripters to bind a key just to the cmdtoserver part, meaning every keypress after that first one will do a full strength jump.
#2
09/02/2008 (8:43 am)
There is a charged resource code, that uses energy, i dont have it off hand but seach is your friend. Top right corner.
#3
09/03/2008 (12:33 pm)
Thanks so much the search turned up great Edward, and Andrew your suggestions will be used as well, thanks so much.