# Adjust world gravity at runtime?

**URL:** <https://forums.unrealengine.com/t/adjust-world-gravity-at-runtime/404916>\
**Category:** World Creation\
**Tags:** gravity, World-Settings, unreal-engine, runtime, level-blueprint, question, Blueprint\
**Created:** [September 18, 2017, 11:20pm UTC](https://forums.unrealengine.com/t/adjust-world-gravity-at-runtime/404916 "2017-09-18T23:20:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TorQueMoD](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/torquemod/32/710746_2.png) [@TorQueMoD](https://forums.unrealengine.com/u/TorQueMoD)\
**Post date:** [September 18, 2017, 11:20pm UTC](https://forums.unrealengine.com/t/adjust-world-gravity-at-runtime/404916/1 "2017-09-18T23:20:06Z")

</div>

Is it possible to adjust the world gravity settings at runtime? I know you can GET the values of the World Settings via the level blueprint but it doesn’t let you SET them.

Thanks!

---

<div class="post-metadata">

**Author:** ![TorQueMoD](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/torquemod/32/710746_2.png) [@TorQueMoD](https://forums.unrealengine.com/u/TorQueMoD)\
**Post date:** [September 24, 2017, 3:26am UTC](https://forums.unrealengine.com/t/adjust-world-gravity-at-runtime/404916/2 "2017-09-24T03:26:09Z")

</div>

Anyone know if this is possible? I want it to affect the gravity of all objects, not just the player so I don’t think a physics volume would work.

---

<div class="post-metadata">

**Author:** ![sidno](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sidno](https://forums.unrealengine.com/u/sidno)\
**Post date:** [September 24, 2017, 7:26am UTC](https://forums.unrealengine.com/t/adjust-world-gravity-at-runtime/404916/3 "2017-09-24T07:26:37Z")

</div>

From what I can tell, for any object that is not located in a specifically placed physics volume, it falls back to the “DefaultPhysicsVolumeClass” that is set in the World Settings.

So, I believe if you wanted a global gravity change outside of placed physics volumes, you’d want to potentially add your own DefaultPhysicsVolumeClass that overrides the GetGravityZ function, where you’d apply your gravity changes at runtime.

I haven’t tried this myself, so not sure if that will work or if it can be done with blueprints alone. Looks like it might require some C++ work to expose ADefaultPhysicsVolume as a BlueprintType, or might be easier at that point to just derive your own DefaultPhysicsVolume in code (or just add a GetGravityZ override directly to ADefaultPhysicsVolume) and expose gravity scale properties used in the overridden GetGravityZ that can be tweaked via blueprint as needed.

---

<div class="post-metadata">

**Author:** ![thin\_line](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@thin\_line](https://forums.unrealengine.com/u/thin_line)\
**Post date:** [October 22, 2017, 5:01pm UTC](https://forums.unrealengine.com/t/adjust-world-gravity-at-runtime/404916/4 "2017-10-22T17:01:03Z")

</div>

Hey, I had a similar situation where it required me to change world gravity at real-time. After searching through, one way to change the global gravity is by using C++. By default UE4 uses ‘Default Gravity Z’ found in Project Settings-\>Engine-\>Physics. In order to change the default gravity to user customed gravity, we can make use of WorldSettings.h class in your actor class.  
According to the class:

> **[AWorldSettings](https://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/GameFramework/AWorldSettings/)**
>
> Actor containing all script accessible world properties.

with ‘bGlobalGravitySet’ to true and setting the GlobalGravityZ=‘YourFloatGravity’.

One small way to implement would be:  
AWorldSettings\* MyWorldSetting=GetWorldSettings();  
MyWorldSetting-\>bGlobalGravitySet=true;  
MyWorldSetting-\>GlobalGravityZ = 900.f;

Hope this helps.

---

<div class="post-metadata">

**Author:** ![mckay421](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mckay421](https://forums.unrealengine.com/u/mckay421)\
**Post date:** [February 5, 2024, 10:41am UTC](https://forums.unrealengine.com/t/adjust-world-gravity-at-runtime/404916/5 "2024-02-05T10:41:19Z")

</div>

I tried to use this code, but GetWorldSettings is unavailable function for me

---

<div class="post-metadata">

**Author:** ![nikopopol](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@nikopopol](https://forums.unrealengine.com/u/nikopopol)\
**Post date:** [May 26, 2024, 7:04pm UTC](https://forums.unrealengine.com/t/adjust-world-gravity-at-runtime/404916/6 "2024-05-26T19:04:14Z")

</div>

Following this post I successfully implemented world gravity Z at runtime : [Changing world gravity with custom C++ node in blueprints not working during runtime](https://forums.unrealengine.com/t/changing-world-gravity-with-custom-c-node-in-blueprints-not-working-during-runtime/560926)
