Skip to content

Instantly share code, notes, and snippets.

@j0z
Created June 2, 2013 20:23
Show Gist options
  • Save j0z/5694831 to your computer and use it in GitHub Desktop.
Save j0z/5694831 to your computer and use it in GitHub Desktop.
var float JumpForce;
var bool CanJump;
var int jumpTime;
exec function BeginJump()
{
if(Physics == PHYS_Walking)
{
jumpTime = 0;
Velocity.Z = 0;
JumpForce = 100;
CanJump = TRUE;
}
//This loop finishes regardless of whether the key is still held down or not.
if (jumpTime < 50 && JumpForce > 0)
{
SetPhysics(PHYS_Flying);
CanJump = FALSE;
Velocity.Z = Velocity.Z + JumpForce;
JumpForce = JumpForce-jumpTime;
jumpTime = jumpTime + 1;
`log("jumpTime: "@jumpTime);
`log("Velocity Z: "@Velocity.Z);
`log("JumpForce: "@JumpForce);
BeginJump();
}
EndJump();
}
exec function EndJump()
{
SetPhysics(PHYS_Falling);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment