Page 1 of 1

Platforming Physics

Posted: Thu Jan 01, 2009 3:43 pm
by tcmg
Hi all,

I've just started getting into Lua and LOVE. I've never used Lua before but I'm a big fan of JavaScript and Python - Lua reminds me of a combination of those two languages. Plus LOVE is really neat as well, especially the built-in physics. I've previously used PyGame and I think having physics provided is a big boon.

Anyway, speaking of physics, I thought a good first step to learning Lua and LOVE would be to program some platforming movement. I've setup 'the world' and created the body, attached the shape, got the ground as another shape to collide with. There's gravity, walking left, walking right and jumping. However, I'm confused as to why when ever I apply movement: walking or jumping, I find the new movement seemingly overrides the existing forces or velocity of the body. I'm not sure if the forces I'm applying are too strong? Or if I'm meant to be taking the existing speed into account when I apply new forces. I expected the physics engine to take care of that for me.

I've attached the existing code, sorry if the Lua code is hacky - I'm new to this!

Can anyone suggest why the movement is so jerky? [left and right arrow keys to move, space to jump]

PS: What's with the "obey" in everyone's avatars? Is it a requisite for using the forum? :D *edit:* ah, I just read the post urging members to do this... bizarre!

Re: Platforming Physics

Posted: Sat Jan 03, 2009 10:35 am
by Dr. Magnusson
Fairly sure there's a function for getting the velocity of an object, is it not as simple as adding the two together?

Re: Platforming Physics

Posted: Sun Jan 04, 2009 3:37 am
by rude
(I have looked into this, and I also find it peculiar. You made me realize that I've never really used impulses/forces that much during testing, I've generally just been using gravity. :ehem: I always look at the source to check for obvious bugs when people are having problems, but I couldn't find any this time. Yes, I found it necessary to parenthesize my entire post).

Re: Platforming Physics

Posted: Sun Jan 04, 2009 4:43 am
by osgeld
rude wrote: I just thought it would be funny if all the avatars on every page said "OBEY" (OBEY, OBEY, OBEY). New users will be all liek "ZOMFG, why do all the avatars say `OBEY`lol". It will be funny. Some day ...
well um, heh :|