Simulating gravity with slowmotion

M

Malte Landgren

Guest
Hi I'm currently working on a strategic space game where in you control a space ship and shoot projectiles, all affected by gravity generated from nearby planets. This currently works fine as is but I was wondering how I would go about implementing slowmotion/speedup of time in the gravity simulation? The usual method of simulating slowmotion by simply multiplying the "hspeed" and "vspeed" by something like "timemodifier = 0.5;" wont work in this case since that would simply reduce/increase the observed effect of the planets gravitational pull.

This is currently how I'm calculating gravity in the bullet and player objects:
with obj_attractor
{
var F = global.G * (mass*other.mass)/sqr(distance_to_point(other.x, other.y));
var a = point_direction(other.x, other.y, x, y);
other.hspeed += F/other.mass*dcos(a);
other.vspeed -= F/other.mass*dsin(a);
}

Thanks!
 

samspade

Member
Hi I'm currently working on a strategic space game where in you control a space ship and shoot projectiles, all affected by gravity generated from nearby planets. This currently works fine as is but I was wondering how I would go about implementing slowmotion/speedup of time in the gravity simulation? The usual method of simulating slowmotion by simply multiplying the "hspeed" and "vspeed" by something like "timemodifier = 0.5;" wont work in this case since that would simply reduce/increase the observed effect of the planets gravitational pull.

This is currently how I'm calculating gravity in the bullet and player objects:
with obj_attractor
{
var F = global.G * (mass*other.mass)/sqr(distance_to_point(other.x, other.y));
var a = point_direction(other.x, other.y, x, y);
other.hspeed += F/other.mass*dcos(a);
other.vspeed -= F/other.mass*dsin(a);
}

Thanks!
Use delta time and the formulas from this video:


While this video is about going from 30 - 60 fps, the basic math is the same - you want to know how to get the same number regardless of how many frames. Once you can do this, you can use delta time and simply speed up or slow down.

I do this in one of my projects to accomplish slow motion. I run a normal delta time and a gameplay delta time which is just normal delta time * modifier.

It sounds like work, and it is, but the sooner you set it up, the better as the more calculations you have to go back to change the more work it will be.
 
M

Malte Landgren

Guest
Thanks a lot man! Really helped me out and managed to implement it without much trouble at all!
 
Top