Page 1 of 1

strange gravity/yvelocity problem

PostPosted: Tue Oct 01, 2013 2:41 pm
by prav
hi! i fiddled around a bit with yvelocity and canjump variable. my first try was successful, then GE crashed and i had to start over, now my actor is sort of bouncy when jumping, it looks weird. i have tried changing the values of Draw Actor>Script Editor> yvelocity=+XX; a bit but i just can't seem to get it to work properly, im gonna post all the entries i think are important below.

first off i made a variable called "canjump" (actor, integer)
then i made some entries :

Script: player -> Draw Actor
Code: Select all
yvelocity = + 8;


Script Editor: player -> Key Down (w, Atleast one key is pressed)
Code: Select all
if(canjump==1)
{
yvelocity=-50; //i have tried lower values here aswell
canjump=0;
}


Script Editor: player -> Collision (Top side of floor2)
Code: Select all
canjump=1;



does anybody know what i did wrong, or what can produce this choppy bouncy behavior?
thanks!

Re: strange gravity/yvelocity problem

PostPosted: Tue Oct 01, 2013 3:31 pm
by Turon
I am not exactly a Game Editor Expert or anything but I know how to fix your problem. :)
I reconstructed your situation and I found your gravity to be part of the problem
I suggest you use
Code: Select all
yvelocity++;
for gravity.

Your Spacing in the code also effected things greatly.
Jump Code.
Code: Select all
if (canjump == 1)
{
    yvelocity = - 12;
    canjump = 0;
}

Re: strange gravity/yvelocity problem

PostPosted: Tue Oct 01, 2013 7:14 pm
by skydereign
Yeah, the problem is that you are setting yvelocity to positive 8, instead of increasing yvelocity by 8 every frame. If you switch it to look like this it will work.
Code: Select all
yvelocity+=8;

Re: strange gravity/yvelocity problem

PostPosted: Tue Oct 01, 2013 10:38 pm
by prav
oh right! i see now, thanks alot guys.

and i might be wrong on this, but it should make little difference if i put in spaces between right?
anyways, it does work like a charm now.
so thanks again.