Jump code

Ganu

  • Posts: 224
Hi, I`m trying to write code that will not let me jump when I`m in the air I wrote major code but it works like double jump, which is not the goal.
Currently waiting for joints in stencylworks.

AnachroNia

  • Posts: 72
I hate this forum! When I press reply it hides the code...

But anyway... what is the point of 'tell this to do bla bla'.... and to have this code there?

What exactly is the goal? You can just use the Jump behavior and just remove the 'on ground' check - but this will make 'endless jump' :) You can add something like 'after 1 sec - set on ground = true'. You'll be able to jump every 1 sec even in mid air.

Ganu

  • Posts: 224
I didn`t need endless jump. I want to make player jump only if he got contact with the ground, Where is the point of jumping in the air.

PS: I used message block just to learn how they work.
Currently waiting for joints in stencylworks.

AnachroNia

  • Posts: 72
It's basically calling a method on an object. But you can't use parameter. Maybe the idea was something like custom events. It sux, but maybe it's easier to understand for some people using design mode.

Oh, I didn't see the 'not'. Just use the "Jump" behavior in the forge :)

Ganu

  • Posts: 224
Just use the "Jump" behavior in the forge :)
I don`t want to be lazy.
Currently waiting for joints in stencylworks.

YellowAfterlife

  • Posts: 13
In short...

Welcome to world of Box2D collision detection!

You see, things here are not like anywhere else here.
There are always many ways of creating something, but only few of them work. Very few.
I prototyped 'bounding box' collision detection method this morning, and guess what - a shape that stays entirely inside the main object reports collision when object hits walls at high speed. That means that event order messes up entirely sometimes.

So, until you shall know everything about b2d, you better stick to standard behaviours.

Ganu

  • Posts: 224
But I want my character to jump once per collision with ground, do I ask for too much?

I think double jump problem is inside queue of code execution. I think that after jump player once again collides with ground.

Tripple jump -,-.

« Last Edit: August 21, 2011, 02:46:06 am by Ganu »
Currently waiting for joints in stencylworks.

coleislazy

  • *
  • Posts: 2607
I would check out the platform behavior pack and see how it works inside the On Ground behavior.

Ganu

  • Posts: 224
I would check out the platform behavior pack and see how it works inside the On Ground behavior.
Would be great I`m still stuck here.
Currently waiting for joints in stencylworks.

Joe

  • *
  • Posts: 2480
I would check out the platform behavior pack and see how it works inside the On Ground behavior.
Would be great I`m still stuck here.

I think he's actually advising you to check it out for yourself.

Ganu

  • Posts: 224
I would check out the platform behavior pack and see how it works inside the On Ground behavior.
Would be great I`m still stuck here.

I think he's actually advising you to check it out for yourself.

I tried.
Edit: And finally I`ve made it. Just need to change space is DOWN not pressed.

« Last Edit: August 22, 2011, 02:19:18 am by Ganu »
Currently waiting for joints in stencylworks.

AnachroNia

  • Posts: 72
So after a long battle... you almost made the behavior in the forge.... but...

Let's think a little about your logic.

1st you check if the actor is on the ground. Ok. Most of the time the actor will be on the ground so your script will go to the second check - if space is pressed. Each frame you'll execute 2 checks.

If you change the order - 1st check if space is pressed... well - the player will press space only when he wants to jump. So each frame you'll have 1 check.

coleislazy

  • *
  • Posts: 2607
I would do:

If <<Space is down> and <OnGround = true>>

Ganu

  • Posts: 224
So after a long battle... you almost made the behavior in the forge.... but...

Let's think a little about your logic.

1st you check if the actor is on the ground. Ok. Most of the time the actor will be on the ground so your script will go to the second check - if space is pressed. Each frame you'll execute 2 checks.

If you change the order - 1st check if space is pressed... well - the player will press space only when he wants to jump. So each frame you'll have 1 check.
Yes you are right, I have changed it. Thanks.
Currently waiting for joints in stencylworks.