Per-Entity Gravity
Posted: Sun Apr 19, 2015 6:15 am
It'd be pretty neat if we could specify a gravity vector on each entity rather than in the Space.
A simple way to accomplish this in a non-changing manner would be to use something along the lines of a Nullable<Vector3> -> if it's null, use Space.Gravity, otherwise, use the value input.
In theory, this should be a relatively simple addition, just use Entity.Gravity rather than Space.Gravity.
This would allow all sorts of fun tricks - entities that are floating (EG in water or a zero-grav chamber or whatever) and thus have no gravity pull. Or perhaps a very very large space consisting of multiple planets, and each entity's gravity is the sum of all planet's gravity's adjusted for distance between the entity and the planet. Or even allowed mcmonkey to go mad with power as he does in the Quake3 Engine:: http://social.xfire.com/videos/4f99e4
Who has per-entity gravity?
Bullet does.
Even Quake (not even a physics engine) has it available.
Is this workaround-able?
Yes. Somewhat. Every tick, apply an impulse that counters the standard effect of gravity, then a second one that applies the new gravity. But this is, of course... excessive. Three forces are applied to every entity involved every tick, that's too much. And it's not even perfect, as the internal code isn't exactly the same as Impulse(gravity * TimeStep) every tick. (or at least I think it's more than that. Acceleration in the real world doesn't actually work like that, that's merely a fair estimate of how it works.)
A simple way to accomplish this in a non-changing manner would be to use something along the lines of a Nullable<Vector3> -> if it's null, use Space.Gravity, otherwise, use the value input.
In theory, this should be a relatively simple addition, just use Entity.Gravity rather than Space.Gravity.
This would allow all sorts of fun tricks - entities that are floating (EG in water or a zero-grav chamber or whatever) and thus have no gravity pull. Or perhaps a very very large space consisting of multiple planets, and each entity's gravity is the sum of all planet's gravity's adjusted for distance between the entity and the planet. Or even allowed mcmonkey to go mad with power as he does in the Quake3 Engine:: http://social.xfire.com/videos/4f99e4
Who has per-entity gravity?
Bullet does.
Even Quake (not even a physics engine) has it available.
Is this workaround-able?
Yes. Somewhat. Every tick, apply an impulse that counters the standard effect of gravity, then a second one that applies the new gravity. But this is, of course... excessive. Three forces are applied to every entity involved every tick, that's too much. And it's not even perfect, as the internal code isn't exactly the same as Impulse(gravity * TimeStep) every tick. (or at least I think it's more than that. Acceleration in the real world doesn't actually work like that, that's merely a fair estimate of how it works.)