Box Jump side to side

Hi all.
Im wanting to have a box only be able to move by juming to the side. I don’t want it to move flat horizontally on the ground without jumping, and I also dont want it to be able to freely move while in the air.

Thanks all


I don’t really understand what effect you are trying to make. Are you talking about a jump effect like the impossible game?

If you’re talking about only being able to move while touching the ground, you can set a property to change to True while touching the “ground” property and False when not, then only allow movement while touching the ground.

If your object is a Character type (physics settings) you may be able do that (never tested) by checking the onGround property:

obj = your game object
character = bge.constraints.getCharacter(obj)
if character.onGround == True: …it can jump with jump() and walkDirection to make it jump in a specific direction

if onGround is False then you simply avoid applying the logic part that makes the player control the movement.

If the object is a dynamic one you can check if it is on ground with ray cast:

obj = some object
pos = obj.worldPosition.copy()
pos.z -= 10
hit, point, normal = obj.rayCast(pos, None, 100)
if point != None: distance = (point - obj.worldPosition).length … then check if distance if bigger than the player radius and so on

Thank you for your response MrPutuLips

I looked at the impossible game, and that looks like a box jumping vertically while the ground plane moves. So no on that count.

I have added the collision property I had from the jump and added it to the left and right, which kinda works. It limits the movement while in the air, but it doesn’t carry the motion from on the ground

Here is an animated example.


You could try animating it then using a ping pong action?

Here I rigged up a demo of how to do this for you. All in logic bricks too! here it is:

Thank you so much for setting this up. but its not quite what I want.

I have made another animated concept with a bit more detail.

I want the spacebar input to be relative to the length of time it is push for.
If you see from the video their is no motion of the box while in the air other than that of its original motion.

Hopefully this helps.

Thanks again for the setup, hopefully you’ll find it in your heart to help me some more.

I’ll look into it. Thanks.

there’s tutorials about precise platformer input on youtube, go look some up! It takes some time to set up in logic bricks and no one wants to make your game for you when they could be making their game

Fair enough. Thanks for the input.

Ok, so to charge a property,

Keypress space----------------------and----add 1 to property “jumpCount”
Property jumpCount min:0 max:120–/
Keypress space invert-------and------jump=1
jumpcount does not =0------/

If jump =1--------and-------jump=0




This charges up a property, but uses it in more ways then 1