Page 1 of 1

A small problem .

PostPosted: Wed Feb 20, 2008 7:14 am
by kingqui
Can som1 help me with this i hav added the char.to walk and jump but when he jumps you can keep on pressing the spacebar to jump which is annoyin becoz i only want him to jump once at a time can any1 fix this and perhaps explain how uu done it,
also when i walk over a particular surface i fall??? dont know why??
One more thing i want to add friction to my walking i hav tried but not succeded by adding an actor, using the keydown event typing in xvelocity = 5; and on the draw actor xvelocity = xvelocity + 1 but the animation jsut goes off to the right can u explain and hep on this topic too plz??
plz help and explain.. =)

Re: A small problem .

PostPosted: Wed Feb 20, 2008 10:51 am
by Thanx
You need a variable, that is 1 while you are colliding, and when you stop colliding, it is 0. In the jump, use an if statement, like this:
Code: Select all
if(collidevariable == 1)
{
    code for jumping goes here...
}

This way you will jump only when you're colliding with the platform...
I'm not sure wether I understand your problem, but I think you mean, that your actor doesn't stop. So, in the Key up, of the actor, you must say xvelocity = 0; So that it stops. But I don't know what you mean by adding friction... :(
Anyway, I hope this helped! :)