Page 1 of 1

CanJump problem

PostPosted: Wed Nov 11, 2009 10:17 am
by MrJolteon
How can I use the CanJump function?
I use a code already, but it don't work:
On player\draw actor i have this code:
Code: Select all
if(canyoujump==1)
{
 yvelocity-8;
}
if(canyoujump==0)
{
 yvelocity-0;
}
and on player\key down space I have
Code: Select all
if(canyoujump==1)
{
 yvelocity-8;
 canyoujump=0;
}
else
{
 yvelocity-0;
}
and on collision I have
Code: Select all
canyoujump=1;
PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_SPECIFIED_MASS, 1.000000, 1.000000, 0.010000, 1.000000);
What did I do wrong?

Re: CanJump problem

PostPosted: Wed Nov 11, 2009 12:30 pm
by skydereign
You don't set yvelocity equal to anything, you simply subtract. To do anything at all you need the equal sign, otherwise you are not setting the variable. Something else to note is that you put in extra code, which you probably did when trying to fix your problem, the following should work.
player -> keydown space -> script editor
Code: Select all
if(canyoujump==1)
{
    yvelocity=-8;
    canyoujump=0;
}


player -> collision (ground) -> script editor
Code: Select all
canyoujump=1;
PhysicalResponse(MOVE_EVENT_ACTOR_ONLY, USE_SPECIFIED_MASS, 1.000000, 1.000000, 0.010000, 1.000000);

Re: CanJump problem

PostPosted: Mon Aug 23, 2010 6:45 am
by MrJolteon
Thx worked now except that the player actor jumped only 8 px up in the air.

Re: CanJump problem

PostPosted: Mon Aug 23, 2010 6:46 am
by MrJolteon
I need some help with fixing the problem in the post above this one

Re: CanJump problem

PostPosted: Mon Aug 23, 2010 7:14 am
by DilloDude
On DrawActor you need to increase the yvelocity:
Code: Select all
yvelocity += 1;//or some other value

Re: CanJump problem

PostPosted: Mon Aug 23, 2010 7:33 am
by MrJolteon
thx

Re: CanJump problem

PostPosted: Mon Aug 23, 2010 12:11 pm
by lcl
Btw, you'd better use shorter variable names, it's easier to use. :D
Like, just "jump", 'cause "canyoujump" takes a lot more writing... :lol:

Re: CanJump problem

PostPosted: Mon Aug 23, 2010 12:20 pm
by MrJolteon
I use "ALTjump" instead of "canyoujump" now

Re: CanJump problem

PostPosted: Mon Aug 23, 2010 6:04 pm
by lcl
Ok...
But why ALT..? :lol:

Re: CanJump problem

PostPosted: Tue Aug 24, 2010 7:51 am
by MrJolteon
Because I use it in the game i'm currently working on named ALTer(you need to use the ALT keys in that game(that explains the name ALTer))