Topic: Jumping

Hello guys, I'm trying to make the sheep of YoFrankie demo jump, but isn't working.

    if isKeyPressed("SPACE") then
        addCentralForce(Player, {0, 0, 5}, "local")
    end

If I hold the key I got a infinite jump. How I fix that? Thanks!

Last edited by rodolfo (2011-04-15 23:15:58)

Re: Jumping

Hello,

Simply make jump only avaible when Feet is colliding with something, like this :

    -- Jump
    if isKeyPressed("SPACE") then
        if (coll > 1) then
            addCentralForce(Player, {0, 0, 15}, "local")
        end   
    end

Re: Jumping

Vegas wrote:

Hello,

Simply make jump only avaible when Feet is colliding with something, like this :

    -- Jump
    if isKeyPressed("SPACE") then
        if (coll > 1) then
            addCentralForce(Player, {0, 0, 15}, "local")
        end   
    end

Thank you Vegas, now it's ok!

Re: Jumping

i am getting some problem to understand this scripts

Re: Jumping

PunBB bbcode test

In YoFrankie example :
The box in yellow is the "Feet" box.

In the script just after function onSceneUpdate() you can see theres is : coll = getNumCollisions(Feet)

so "coll" is the variable where is stored the number of collision for "Feet"

To describe the jump script below :

If "Feet" is colliding with something, then allow jump
If "Feet" isnt colliding, it wont jump

More complete info on feet box, to quote anael :

Feet box :
It's just a logic thing, if you want to know if the player touch the ground it is a simple way to do it. Because if you test if the main box is colliding with the room, it will detect also when colliding with the walls (we don't want). Because the main box is larger than the feet box, the feet box only touch the ground.

Hope it helps

Last edited by Vegas (2011-05-08 16:13:29)

Re: Jumping

Just joined the forum.. Because I want to learn about scripting... Can someone please give me useful suggestions about it please?
rain chains

Last edited by Rattiee (2011-10-22 09:01:23)