Page 1 of 1

Need some help with Physic module ?

Posted: Fri Jul 31, 2009 2:37 pm
by Neolitik
Hello any ,

I' m on the " physics way" in love.
I want make a Body , Can jump and move ....
But in my code , if i jump my body dont conserve right or left move !
I had search in the LovelBigPlantet code but i m dont understand all :o
i read this : --get the velocity, process the input, and set it, preserves untouched velocity..
i try make but dont work ^^
my code :

Code: Select all

function update(dt)
local x,y=Circle:getVelocity()
Circle:setSleep( false ) 
if love.keyboard.isDown(love.key_right) then
x= 500
end
if love.keyboard.isDown(love.key_left) then
x= -500
end
if love.keyboard.isDown(love.key_space) then
y= -500
end
Circle:setVelocity(x,y)
World:update(dt)
end
any solution welcome ^^ thank for all !

Re: Need some help with Physic module ?

Posted: Sun Aug 02, 2009 5:12 am
by Raider
The code looks correct for a simple set-velocity jumping system.
Could you be more specific about what the problem is?

As in, what do you mean by, "It doesn't conserve left or right movement"?

Re: Need some help with Physic module ?

Posted: Sun Aug 02, 2009 5:34 am
by TechnoCat
Could you post more code? It looks pretty correct to me too.

Re: Need some help with Physic module ?

Posted: Sun Aug 02, 2009 10:13 pm
by Sardtok
Do you mean that you can turn around in mid-air?
Cause, if that's the problem, you would have to put in a check for whether you're in the air too before setting the x velocity.

Re: Need some help with Physic module ?

Posted: Thu Aug 27, 2009 9:26 pm
by LuaNewb
My guess is, that, if you're making a platformer-type game and using the physics module that you found your guy sliding around on the floor like he was in a Super Mario Bros. 2 ice level; and perhaps you wrote some code to kill the X velocity when left and right where not being pressed... I'm guessing this because i've just started with Love and not 20 minuets ago did exactly the same thing ;)

If this is the case, perhaps, check that the player sprite is not colliding with the floor (i.e is in the air) before killing your x velocity.