Help? Problem with jump in logic bricks

Hello im trying to achieve a double jump, but it needs to be light like a 2 or 3 upward valocity
I just dont understand how to add a collision sensor that senses when you collide with the ground so you cant jump more than 2 x?

to see what exactly i am doing look at the .blend below


Snowball jump problem .blend (591 KB)

Okay, well, a solution I have found would be to add a material to the ground then add a touch sensor that reset a jump property(int) to 0 when your object collide with the material “ground”. Then you could increment(+1) the value of jump each time you jump and allow the jump action only if the property jump is = to 1 or 2.

To prevent the floor to reset the jump value when touched by the head of the player, you might want to add an invisible mesh just over the floor wherever you want to reset the jump value. You might also want to add a little delay sensor before resetting just in case the player still touch the ground invisible plane when jumping, which would resent the jump property too soon and allow a third jump.

So, to make it simple :
Touch (material = ground) -> property (set “jump” to 0)
spacebar AND property(jump lower then 2) -> motion (your jump) AND property(add 1 to “jump”)

That should do it.

youll have to be a little more specific…this is actually my very VERy first dabbling in the game engine…so everything is new to me
i am very sorry bout that

Ho, there’s nothing wrong with starting something new, don’t apologize. =P

Okay, I have the feeling you have some startup knowledge but I’ll start over again just to be sure we don,t miss anything.

Okay, so the logic in the game engine works by connecting sensors(that will wait that a specific event come) to actuators(that will produce an action) through controllers(that will pretty much control how the sensors have to be to activate the actuator). You also have a bunch of other things like the collision type, collision bound and other physical property. So far nothing new. An other thing you can do is to add a property to an object. For example, you could have a property called “life” to your character which would contain your character’s life. If you would want to influence this property when a certain event occurs, you would have to do it with a property actuator. If you would want a certain event to happens when your property reaches a certain value, you would have to do it with the property sensor.

And all that is pretty good because that’s what we want for your doublejump. So first, to add a property, you will have to press n in the game logic window. There you should see an “add property” button, press it. Now you have to know that there is multiple sorts of properties. You have boolean(true or false), integer(complete number like 1 -1 0 999999999), float(fractionnal numbers like 1,0 -875,974) and timer(pretty much like a float that goes down with time). Usually, people uses boolean for property that are true or false(like : is the character alive?), integer for number that are always full(like number of coins), float for fractionnal number(like time) and timer…when you feel like it. Note that float could do the job of integer but integer takes less memory and keep the code cleaner so I recommend to prefer it to float when you can. And ho!, there is also the string property. Well, string if for everything that contains letters like name of characters and things like that. For our situation, take an integer and give it an initial value of 0 and call it jump.

Now, the way we want to do it is that we want to increase this property by 1 each time the player press space. So the value will be 1 for the first jump, 2 for the second and so on. We also want to stop the player to jump once the property will = 2, this way he will only be able to jump twice. Finally, we want the jump property to go back to 0 once the player touches the ground, so he will be able to jump again.

So, we need a sensor that will trigger(get activated) each time the player will hit the ground. There are a couple of ways to do that but we’ll do it with the touch sensor. The way this sensor works it by triggering each time the object will touches a given material, so we just have to add a particular material to the ground that will trigger the sensor when the player touches it. Create a basic material and name it “ground”. God back to your sensor and add ground in the given space. Now, create a property actuator. This actuaor works by asking you how you want to influence the property, what property you want to influence and by what number. In our case, we want to reset the default value(0) of our jump property, remember? So just fill the space to make it do that.

Now, create a property sensor. This sensor will detect if our property jump is below 2 (use the interval option in the brick for this one). If the property is, then the sensor will be “true”. Connect this sensor to the the same controller your spacebar sensor is connected. the way it works is that if your controller is set to “AND”, it will check if all your sensors are true. If they are, then it will activate the actuator. As your jump property will increase with each jump, it will reach 2 after the second one and your property sensor will turn false, so the controller won’t let your character to jump anymore until it touches the ground, where the property will go back to 0 and your sensor will turn true again. All we have to do now is to increase the property after each jump. With all my explanations and my last post, you should be able to figure that part by yourself. I still have to let you learn a bit.

I think that, with this, you should be able to get it done. Hope it helped and that the explanations were clear.

lol im lost after the second part where you make the second property… i make then then i dont know where to connect it at… and then i dont where to connect that “if” i connect it across correctly the first time

wait a second and ill post an image of my “results”
here they are ?