Author Topic: Calling The Falling Function  (Read 502 times)

In

Code: [Select]
function Player::
What would I put after :: which calls the falling function to see if the player is falling?

I don't think there is an actual isFalling method, however you could use Player::getVelocity and compare the 3rd value returned.

And for future reference, you could figure this yourself by doing (any player object).dump();

function player::isFalling(%this)
{
     %velocity=%this.getVelocity();
     %yvel = getWord(%velocity,3);
     if(%yvel < -3)
           return 1;
     return 0;
}


edit: then later do if(%player.isFalling()) { %player.kill(); } or w/e you're planning to do
« Last Edit: June 12, 2010, 01:43:41 PM by Triple Nickels »

function player::isFalling(%this)
{
     %velocity=%this.getVelocity();
     %yvel = getWord(%velocity,2);
     if(%yvel < -3)
           return 1;
     return 0;
}


edit: then later do if(%player.isFalling()) { %player.kill(); } or w/e you're planning to do
Fixed. The order starts off with the first being 0, so the third would be 2.
And he may wish to change the value its comparing to in the if statement. For comparison, a downward velocity of about 10-11 is achieved at the end of a straight up and down jump.
« Last Edit: June 12, 2010, 01:49:28 PM by Headcrab Zombie »