Check it out if you are into that sort of thing:
http://www.niksula.hut.fi/~hkankaan/Hom ... avity.html
Interesting article about gravity in games
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Interesting article about gravity in games
When I write def I mean function.
- substitute541
- Party member
- Posts: 484
- Joined: Fri Aug 24, 2012 9:04 am
- Location: Southern Leyte, Visayas, Philippines
- Contact:
Re: Interesting article about gravity in games
Very interesting...
Currently designing themes for WordPress.
Sometimes lurks around the forum.
Sometimes lurks around the forum.
Re: Interesting article about gravity in games
One could call that a second-order approximation, right?
That's a dangerous statement. It's always an approximation unless we can throw an enormous amount of computation at it. Even then, we probably have to settle for a "accurate enough".Accelerating physics are no longer approximation!
Shallow indentations.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Interesting article about gravity in games
Using the term "physics" is wrong there, of course. I think he means that the implementation is aligned with the conventional model used in games, while the "conventional" implementation, is more like an aproximation of that model. The "real" physical phenomenon is not even considered.Boolsheet wrote:That's a dangerous statement.Accelerating physics are no longer approximation!
When I write def I mean function.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Interesting article about gravity in games
This actually explains the problem I had way back when I was creating my first sidescroller prototype and when my framerate would suddenly drop (For instance when my desktop picture would fade from one to another, Löve would have a tendency to drop its FPS to a very low amount) my player jumping would suddenly not be as perfect as it would with a constantly high framerate.
Re: Interesting article about gravity in games
Interesting solution for the problem. I'm of the mindset that any degree of complex game physics should probably done quantized, i.e. that you do the world logic updates at a fixed framerate independent of the video framerate, and things like Box2d make this recommendation also (make a fixed timestep). But for simpler logic, I like this a lot, it has a strange elegance in its simplicity. Thanks for showing us this.
- dreadkillz
- Party member
- Posts: 223
- Joined: Sun Mar 04, 2012 2:04 pm
- Location: USA
Re: Interesting article about gravity in games
Ah classical mechanics! Just a warning to readers, this method only works if the acceleration is constant. If your acceleration is a function of position or velocity, then you will need an approximate method or solve for the differential equation in another way.
- substitute541
- Party member
- Posts: 484
- Joined: Fri Aug 24, 2012 9:04 am
- Location: Southern Leyte, Visayas, Philippines
- Contact:
Re: Interesting article about gravity in games
Just a note. It is still inaccurate for VERY low FPS. Just look at the new algorithm's picture, the 3 FPS example didn't even reach the correct position.
Currently designing themes for WordPress.
Sometimes lurks around the forum.
Sometimes lurks around the forum.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Interesting article about gravity in games
If you're getting 3FPS in a game, you probably won't enjoy playing that game anyway.
Re: Interesting article about gravity in games
I got something little different, but it seams to work just fine with low FPS:
bullet.speedy0 is a initial velocity and it's constant for most of the time.
When an object interacts with something bullet.speedy0 is recalculated and bullet.time is reset
Exemplar in the attachment (left click outside the blue ball to create new object, you can move the blue ball with arrow keys, first blue number is FPS, the other is the object counter)
Code: Select all
bullet.time = bullet.time + dt
bullet.speedy = bullet.speedy0 – 100*gravity*bullet.time
bullet.y = bullet.y - bullet.speedy*dt
When an object interacts with something bullet.speedy0 is recalculated and bullet.time is reset
Exemplar in the attachment (left click outside the blue ball to create new object, you can move the blue ball with arrow keys, first blue number is FPS, the other is the object counter)
- Attachments
-
- gravity.love
- (1.13 KiB) Downloaded 326 times
Who is online
Users browsing this forum: No registered users and 6 guests