Page 1 of 1

Jumping Platform Characters

PostPosted: Thu May 27, 2004 7:53 am
by jazz_e_bob
What is the easiest way to test if an actor is standing on a platform?

The actor should only be able to jump if he is standing on the platform - not already in the air.

jazz

PostPosted: Thu May 27, 2004 10:04 am
by ingsan
Hi, how are you ?

On your Platform actor (On KeyDown > Script), write :

    if(yvelocity == 0)
    {
    Jump;
    }


Heh, mate, we're still on the Move :wink:

PostPosted: Thu May 27, 2004 10:58 am
by jazz_e_bob
Hi Ingrid.

I am well.

Had a major system crash recently though. Lost a few hours work on microfooty and a few days to rebuild my computer. Working better than ever now though. :)

Glad to hear you are keeping busy. You guys do such amazing work.

The only problem with what you said is that ( yvelocity == 0 ) at the peak of a jump too. :(

Image

PostPosted: Thu May 27, 2004 11:12 am
by ingsan
:? How come there is a yvelocity = 0 at peak of jump ? Do you have gravity on Draw Actor ? Did you put yvelocity = 0 at jump peak so that you obtain gravity ? If that is the case, I have probably a better way of doing that ...

Anyway, for your problem, you can use a variable.
On Collision with Platform, jump = 0;
On CollisionFinish with Platform, jump = 1;
So, onKeyDown, if ( jump == 0 ), Jump Action;

PostPosted: Thu May 27, 2004 11:26 am
by ingsan
Here's what i do for a platform character :

You have two actors : Batman and Ground

Batman
Add Event KeyDown[UP]
Add Script and write :
    yvelocity = -9;

Add Event DrawActor
Add Script and write :
    yvelocity = yvelocity + 1;
Add Event onCollision with TopSide of Ground ( Repeat YES )
Add Script and write :
    yvelocity = 0;


You get a Smooth and gradual jump and gravity :P

PostPosted: Thu May 27, 2004 11:46 am
by jazz_e_bob
Cool.

Thanks for the tip. :)

PostPosted: Thu May 27, 2004 5:36 pm
by ingsan
you're welcome 8)

PostPosted: Sun Sep 11, 2005 1:04 pm
by Snowfly
hi ingsan, i tried your solution. it works fine, except that there is still a very small chance that the player can double-jump (when at the peak of a jump). this is what jazz-e-bob was mentioning.

is there a more elegant solution?

PostPosted: Sun Sep 11, 2005 1:12 pm
by jazz_e_bob
http://www.game-editor.com/forum/viewto ... atform+guy

This uses a second actor to detect the platform.

PostPosted: Mon Sep 12, 2005 2:04 am
by Snowfly
hi jazz-e-bob, platform guy is pretty cool. i'm digging into your code now. :)

the solution i tried was to set a global variable 'int onGround = 0' (my character starts in the air) and setting it to 'onGround = 1' whenever the player touches the ground. When the player presses the jump button, onGround is set to 0.

This pretty much kills the double-jump, but the character is still able to jump when you simply walk off a platform. I tried adding a collision finish script to set onGround to 0 when the character walks off a platform, but it didn't do anything. :(

another bug i'm working around is preventing the character from 'sticking' when you push against a wall mid-jump.

PostPosted: Mon Sep 12, 2005 5:48 am
by jazz_e_bob
Good luck! :)

PostPosted: Mon Sep 12, 2005 1:13 pm
by Snowfly
here's my solution for platform guy:

on collision with platform, set parent of event actor to collide object. set parent to 'no parent' on finish collision with collide object. voila!

next i will try to inherit some momentum from the platform.

PostPosted: Tue Sep 13, 2005 2:39 am
by jazz_e_bob
Well done.

I have added this to my demo and will release it with next GE update.

PostPosted: Mon Sep 19, 2005 8:32 pm
by jazz_e_bob

PostPosted: Fri Jan 27, 2006 7:00 am
by DilloDude
You can also see my solution to the double-jump bug.
http://game-editor.com/forum/viewtopic.php?p=7564&highlight=#7564