# Detect walls and prevent player from jumping on them

My main goal is to have the best jumping experience - (Keep jumping up and down when spacebar is held down, longer jumps when spacebar is held longer), where there is no wall jumps.

Currently, minus a few features I kinda wanted to have, you can only jump (With the Force Motion) only when the spacebar is pressed, in a collision with an object (Walls too). This creates the ability to wall jump, which I do not want. Removing the Collision sensor makes things worse, where you can keep jumping in the air to space.

My question is, how do I use the collision sensor (if it's a good way), and to detect/prevent the player from jumping up walls?

• Check my edited answer, there is the blend to download. – Strapicarus Dec 25 '17 at 14:23

First your problem was that you set the ray sensor range to a kilometers (100000.00), set it to 1 or 2 (1.00), also there is no objects with "walls" propety in your file and the ray should look for ground, i set the higer floating ground to wall and you not able to jump over it, the other i change from ground to floatingGround property so this way the ray's and collisions sensors will not add 2 times the force of jumping when the player is over 2 grounds and add another set of ray and collitions sensors and motion actuator to jump over the floating grounds.

Before edit

Use a ray sensor property ground combined with the kerboard sensor and collision sensor property wall.

PD. Its late here and this gif take to much lol.

• I set it up like you have shown, but for some reason, the Ray sensor is preventing jumping. Also, does this work if I want a cube where it's sides are walls, and the top is ground? – Akados Dec 22 '17 at 4:20
• Increese the range distance, the idea is that when the player jump and it higher than the range in the ray sensor the player will just fall, also make sure that the axis is -z (negative) in the ray sensor. – Strapicarus Dec 22 '17 at 17:51
• In test that i made the ground is below the player and was able to jump higer and able to make doble jump. if you want doble ground over and below the player all you doing is wrong, firts the player will need to be not affected by the world gravity and need to set some sort of doble gravity from the 2 grounds for that the player physics should be static and you need to calculate the forces applies and update the player position with thats calculations. – Strapicarus Dec 22 '17 at 17:51
• What way do you recommend to create a jumping thing like this, that will not double jump, and will not jump off of walls? – Akados Dec 22 '17 at 19:09
• Those 3 points is to activate "true level triggering", which means that the sensor will run every frame, if not checked the sensor only run the first frame. – Strapicarus Dec 25 '17 at 19:33