strange gravity/yvelocity problem

Non-platform specific questions.

strange gravity/yvelocity problem

Postby prav » Tue Oct 01, 2013 2:41 pm

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!
$sudo game
User avatar
prav
 
Posts: 2
Joined: Mon Sep 30, 2013 6:33 pm
Score: 0 Give a positive score

Re: strange gravity/yvelocity problem

Postby Turon » Tue Oct 01, 2013 3:31 pm

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;
}
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: strange gravity/yvelocity problem

Postby skydereign » Tue Oct 01, 2013 7:14 pm

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;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: strange gravity/yvelocity problem

Postby prav » Tue Oct 01, 2013 10:38 pm

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.
$sudo game
User avatar
prav
 
Posts: 2
Joined: Mon Sep 30, 2013 6:33 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron