Frictional Games Forum (read-only)
Simulating changes in gravity - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Articles (https://www.frictionalgames.com/forum/forum-40.html)
+---- Thread: Simulating changes in gravity (/thread-14448.html)

Pages: 1 2


Simulating changes in gravity - Damascus - 04-02-2012

I was messing around with repeated prop forces when I discovered a way to easily simulate changing gravity on an object. Objects with reversed gravity will "fall" upward seamlessly, bouncing and rolling on the ceiling like they normally would on the floor. You can also still grab objects and throw them around, and I had a lot of fun lodging books on the undersides of tables.

AddTimer("AntiGravity", 0.0f, "AntiGravity");

void AntiGravity(string & asTimer)
{
AddPropForce("[ENTITY]", 0, F, 0, "world");
AddTimer(asTimer, 0.01f, "AntiGravity");
}

Formula for calculating Prop Force
M = Mass of Object
G = Gravity Multiplier (2 = double, 1 = normal, 0 = no gravity, -1 = reversed)

F = (1-G) x 9.81M

(Also, forgive me for being a nerd, but since the formula pretty much came out to be Newton's second law, that leads me to believe the game technically uses kg for it's mass units, and Newtons for it's PropForce units. Cool little tidbit.)







RE: Simulating changes in gravity - Adrianis - 04-02-2012

(04-02-2012, 09:07 PM)Damascus Wrote: I was messing around with repeated prop forces when I discovered a way to easily simulate reversing gravity on an object. Once the script is activated, objects will "fall" upward seamlessly, bouncing and rolling on the ceiling like they normally would on the floor. You can also still grab objects and throw them around, and I had a lot of fun lodging books on the undersides of tables.

AddTimer("AntiGravity", 0.0f, "AntiGravity");

void AntiGravity(string & asTimer)
{
AddPropForce("[ENTITY]", 0, X, 0, "world");
AddTimer(asTimer, 0.01f, "AntiGravity");
}

X = 20 * mass of object

If you're extremely delicate about force, I think you can possibly modify it to reduce gravity and even make objects hover. Have fun playing with this!

You can indeed simulate pretty much perfect zero-gravity, with a loop running very fast indeed (0.015 or thereabouts), and the perfect amount of +Y force. For a wine bottle, that is 19.7, and a small throwable box is 118. It is, however, much easier to make a new model and untick 'Has Gravity'. Depends if you want to activate / deactivate it in script

I spent a fair amount of time in a very big room with lots of zero-g boxes after getting that right Tongue


RE: Simulating changes in gravity - Damascus - 04-03-2012

Awesome! I played around with it some more and made some things hover in the air, too bad I can't just run up against things to push them around, I have to actually grab them.

Using your wine bottle example, and playing around with rocks some more, I updated the first post with a formula. One can use it to easily get a Prop Force number to give any object any force of gravity, positive or negative.

It doesn't work on things with multiple bodies with mass (like corpses), as the same force will be applied to every body. I ended up getting a corpse whose back was trying to fall and limbs were trying to rise. Kind of funny looking, but hey.



RE: Simulating changes in gravity - Adrianis - 04-03-2012

Awesome dude nice work, I was just gonna fiddle the sh*t out of every object I included to work out the right amount, but having a formula seems like a much better idea!



RE: Simulating changes in gravity - Homicide13 - 04-05-2012

Where can I find the mass of an entity? I feel like I've sen such an option somewhere but I can't find it now...



RE: Simulating changes in gravity - Kman - 04-05-2012

I'd love to see some sort of video of this, I MIGHT have gravity shifting/zero gravity sequences in my custom story and I thought it'd be nice to see how it looks before making a decision.


RE: Simulating changes in gravity - Adrianis - 04-05-2012

(04-05-2012, 10:28 AM)Homicide13 Wrote: Where can I find the mass of an entity? I feel like I've sen such an option somewhere but I can't find it now...
Its listed a property in the Model Editor for the Body of the model, first on the list.

Quote: I'd love to see some sort of video of this, I MIGHT have gravity shifting/zero gravity sequences in my custom story and I thought it'd be nice to see how it looks before making a decision.
Its super easy to set up dude, unfortunately I dont have any video capture software so I can't upload anything. Just stick a few small boxes in your existing map, use a timer in OnStart to set off another timer running every 0.015s looping AddPropForce("name of box", 0, 118, 0, ...)

As long as the timer is right, the effect is flawless, the way objects bounce around the room is perfect for zero-g, only issue is you cant push into things and have them move, meaning you can jump ontop of floating objects. Not so good.




RE: Simulating changes in gravity - Homicide13 - 04-05-2012

After experimenting around with this a bit I have found one problem: air friction. Although an object might ignore gravity, it still slows down due to air friction. Does anybody know where the config files are for air friction controls (assuming there are any?)



RE: Simulating changes in gravity - Adrianis - 04-05-2012

(04-05-2012, 09:35 PM)Homicide13 Wrote: After experimenting around with this a bit I have found one problem: air friction. Although an object might ignore gravity, it still slows down due to air friction. Does anybody know where the config files are for air friction controls (assuming there are any?)
Never really considered that as the object would slow down in an environment with atmosphere. I doubt there is, but I'll let you know if I find a way of doing it. Likely there would be some performance issues having an entity never stop moving, but on a small scale shouldn't be too bad.



RE: Simulating changes in gravity - Damascus - 04-06-2012

(04-05-2012, 10:56 AM)kman Wrote: I'd love to see some sort of video of this, I MIGHT have gravity shifting/zero gravity sequences in my custom story and I thought it'd be nice to see how it looks before making a decision.
I might make a video tonight, cause I have the software. I'll probably fill a room with some zero-g boxes and make four rocks: normal weight, half weight, zero weight, reverse weight. Then fling them around like a madman. Big Grin