Help with gavity

Hi All,

I am developing an endless runner game in which a character is running automatically through the floor and a camera is following the character in order to be always at the middle of the screen. My concern/issue/problem is regarding the physics and the applyLinearImpulse() function. Let me try to explain what is my problem and then if you have any chance to help me (will be greatly appreciated).

I’d like the player to jump but (and this is the problem) every time the player jump (and of course the screen is moving) appears like to player is floating on the sky. I do need the player jump and then to fall down as soon as it can. Let me better explain, my player jump as an invert “U” and I need to jump as and invert “V”or…… (how difficult is to explain)to be a tight invert “U”; to keep in the air the less minimum time possible. My intention is to jump quickly and then once he has to fall down, to do it as the quick velocity.

I do appreciate and sorry if I was not clear.

Please double check the screenshot

local physics = require “physics”

physics.start()

physics.setGravity( 0, 9.8 )

    physics.addBody( player, { density=1.0, friction=1.0, bounce=0.0 } )

local onButtonJumpEvent = function (event)

    if run == false then return end

    if event.phase == “began” then

      if player.canJump then

        

        player:applyLinearImpulse(0, -10, player.x, player.y)

        

      end

    end

  end   

I’m sry, I can’t see the screenshot. Is there anywhere a link? So as I understand you’re just not content with your physics settings? You can set gravity higher (often in games you don’t use the world’s real gravity) or make your character heavier. Then he’ll fall down quicklier, you just need to increase your impulse. If both are not an option for whatsoever, you could check for the character’s vertical movement (eg did it change from + to - ) and then add an impulse to accelerate your character’s fall speed. Hope that helps.

Greetings Dominik

PS: Ah now I get your U->V problem. I guess if you can’t tweak the settings until you are content, you could go with another impulse.

I’m sry, I can’t see the screenshot. Is there anywhere a link? So as I understand you’re just not content with your physics settings? You can set gravity higher (often in games you don’t use the world’s real gravity) or make your character heavier. Then he’ll fall down quicklier, you just need to increase your impulse. If both are not an option for whatsoever, you could check for the character’s vertical movement (eg did it change from + to - ) and then add an impulse to accelerate your character’s fall speed. Hope that helps.

Greetings Dominik

PS: Ah now I get your U->V problem. I guess if you can’t tweak the settings until you are content, you could go with another impulse.