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