Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(Script help) - Removing or manipulating gravity physics
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#1
(Script help) - Removing or manipulating gravity physics

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.
03-02-2012, 01:32 AM
Find
Strembitsky Offline
Senior Member

Posts: 254
Threads: 37
Joined: Feb 2012
Reputation: 3
#2
RE: (Script help) - Removing or manipulating gravity physics

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/amn..._functions

The Nightmares v1.0 - Dreadful Fires WIP
03-02-2012, 01:41 AM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#3
RE: (Script help) - Removing or manipulating gravity physics

(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/amn..._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

03-02-2012, 02:10 AM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#4
RE: (Script help) - Removing or manipulating gravity physics

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:

03-02-2012, 02:35 AM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#5
RE: (Script help) - Removing or manipulating gravity physics

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.

03-02-2012, 03:26 AM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#6
RE: (Script help) - Removing or manipulating gravity physics

Awesome, thanks guys I'll check this stuff out.
03-02-2012, 10:25 AM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#7
RE: (Script help) - Removing or manipulating gravity physics

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.
03-03-2012, 07:44 PM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#8
RE: (Script help) - Removing or manipulating gravity physics

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. >_>

03-04-2012, 05:33 AM
Find




Users browsing this thread: 3 Guest(s)