Description
Returns the AWorldSettings actor for the world this actor is in. WorldSettings holds global parameters like gravity, KillZ, and world time dilation.
Caveats & Gotchas
- • This calls through GetWorld()->GetWorldSettings() — it is a convenience wrapper. If you call it many times per frame, cache the result rather than calling through the chain repeatedly.
- • For dynamically spawned actors placed into a sublevel, the returned WorldSettings always comes from the persistent level, not the sublevel — there is only one WorldSettings per world.
Signature
class AWorldSettings* GetWorldSettings() const Return Type
class AWorldSettings* Example
Read world gravity for a custom physics calculation C++
AWorldSettings* WS = GetWorldSettings();
if (WS)
{
float GravityZ = WS->GetGravityZ();
FVector CustomForce = FVector(0.f, 0.f, GravityZ * CustomGravityMultiplier);
MyPhysicsComponent->AddForce(CustomForce);
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?