Frictional Games Forum (read-only)
(Script help) - Removing or manipulating gravity physics - 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 Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: (Script help) - Removing or manipulating gravity physics (/thread-13693.html)



(Script help) - Removing or manipulating gravity physics - Adrianis - 03-02-2012

I have looked everywhere I can think of for an answer to this question, but it seems its not a common problem.

Does anyone know of any way, or can think of any way, that you can remove gravity, or at least simulate it (even if this means applying all sorts of directional force to an object, in a tedious and inefficient manner)

If anyone knows if you can manipulate the gravity physics, or can think of a way of faking it on the player or an entity, please let me know

Thanks.



RE: (Script help) - Removing or manipulating gravity physics - Strembitsky - 03-02-2012

You can set the static physics of it through scripts.

You can also push it with scripts.

Welcome to the world of scripting: http://wiki.frictionalgames.com/hpl2/amnesia/script_functions


RE: (Script help) - Removing or manipulating gravity physics - Adrianis - 03-02-2012

(03-02-2012, 01:41 AM)Strembitsky Wrote: You can set the static physics of it through scripts.

You can also push it with scripts.

Welcome to the world of scripting: http://wiki.frictionalgames.com/hpl2/amnesia/script_functions
Thanks for your help, I'm already in the world of scripting Smile

"void SetPropStaticPhysics(string& asName, bool abX);

Activates/deactivates the physics of a prop. Setting as true will make entities static in midair.
"

Its the 'static in midair' part that gets me. Does that mean the thing the player will not be able to interact with it physically? The effect I'm looking for is a lack of gravity, having a truely static object would rather break the impression of a lack of gravity.

I figured you could use AddProp/BodyForce to fake it, but getting the effect just right would take sometime, and if it was never intended for this then there could be some 'unforseen consequences' when the player tries to grab or move the thing




RE: (Script help) - Removing or manipulating gravity physics - flamez3 - 03-02-2012

In Scroobs castle, we did the same kind of thing. I'm not at my PC right now so if you downloaded it and look at the script for the "Library" map you could figure out how we did it c:


RE: (Script help) - Removing or manipulating gravity physics - palistov - 03-02-2012

It depends on what you want to manipulate. If it's the player, it requires a lot of painstaking testing to get decent values. There are some threads about this topic somewhere deeper in the forum pages, but if you find them you might be able to find values which work. You'll need a loop that fires off every 0.0166 seconds to get smooth and steady control.

However, if you want to control entities, it simply becomes a matter of pushing an object when and only when you want it to be moved. You simply create a custom entity and un-check 'Has Gravity' on the body's properties.


RE: (Script help) - Removing or manipulating gravity physics - Adrianis - 03-02-2012

Awesome, thanks guys I'll check this stuff out.



RE: (Script help) - Removing or manipulating gravity physics - Adrianis - 03-03-2012

Pretty much got it, for anyone who may be interested in the answer, this is what I did

To test, I made a floating bottle. Very exciting stuff. Thanks Palistov for the timer value.

void OnStart()
{
AddTimer("floatbottle", 0.0166, "floatbottle");
}

void floatbottle(string &in asTimer)
{
AddPropForce("floatingbottle", 0, 19.7, 0, "world");
RemoveTimer("floatbottle")
AddTimer("floatbottle", 0.0166, "floatbottle");
}

And lo, the bottle did float

This is the right amount of force to keep the bottle perfectly still in midair. When you grab and throw it, the effect of there being no gravity is pretty much as perfect as you could want it, but it will need to be applied to each entity individually by adding them into the looping function. No idea what performance implications there could be, but I intend to test that soon. When the bottle breaks, the pieces still fall downwards which kinda spoils the effect somewhat.

I can also get the player to float, by adding 'AddPlayerBodyForce(0, 1400, 0.0, false)' to the function, similar to what Elven did in the 'Floating Tongue' thread, but you can't control yourself properly in midair, so I'm not sure its all that useful.



RE: (Script help) - Removing or manipulating gravity physics - palistov - 03-04-2012

Congrats on getting it to work. Seems like it'll be a bit of good fun in some situations. Gonna bookmark this one in case people start asking how to make floating naked men in the future. >_>