# Zero Gravity: Usage & Setup Guide

#### **What Zero Gravity Does**

Zero Gravity disables all gravity-based surface detection and rotation alignment, placing the character in full weightlessness.

* No gravity direction is applied
* No surface probes run
* Character enters `MOVE_Flying` movement mode
* `GravityScale` is set to 0
* Fully server-authoritative and replicated with local prediction for responsive feel
* Safe to use alongside custom flying setups via `bExternalFlyingActive`

***

#### **Required Setup**

**1. Character Setup**

Your character must use `UGravityMovementComponent`.

* Replace `CharacterMovementComponent` with `GravityMovementComponent`
* Replication must be enabled (default in constructor)
* Works with standard `ACharacter`

**2. Place the Gravity Field**

Drag `BP_GravityField` into the level and configure:

* `OverlapRadius` — defines the trigger volume size
* `ZeroGravityExitGravityScale` — controls gravity restoration on exit

***

#### **Entering Zero Gravity**

Call from a server-authoritative context:

```
GravityMovementComponent->EnterZeroGravity();
```

Or via the Gravity Field:

```
ApplyEnterZeroGravity()
```

This can be called from Begin or End Overlap. Safe to use from either.

What happens on enter:

* `bZeroGravityActive` is set to true
* Movement mode is set to `MOVE_Flying`
* `GravityScale` is set to 0
* All gravity probes and rotation alignment stop immediately
* Replicated to all clients with local prediction on the owning client

***

#### **Exiting Zero Gravity**

```
GravityMovementComponent->ExitZeroGravity(ZeroGravityExitGravityScale);
```

* `ExitZeroGravity` is idempotent — safe to call unconditionally from any overlap without affecting characters not in zero gravity
* Automatically called when any other gravity Apply function is called on the Gravity Field
* `ZeroGravityExitGravityScale` restores `GravityScale` on exit — exposed on both the component and the Gravity Field

What happens on exit:

* `bZeroGravityActive` is set to false
* Movement mode is set to `MOVE_Falling`
* `GravityScale` is restored to `ZeroGravityExitGravityScale`
* `GravityDirCached` is resynced from the character's current physical rotation
* Gravity probes and rotation alignment resume immediately

***

#### **Custom Flying Setup Integration**

If your character has a custom flying system:

```
bExternalFlyingActive = true;
```

When true:

* `EnterZeroGravity` will not override the movement mode
* `ExitZeroGravity` will not override the movement mode
* `GravityScale` is still managed correctly
* Your flying system remains in full control of movement mode

***

#### **Networking & Replication**

* `bZeroGravityActive` is replicated
* `bExternalFlyingActive` is replicated
* `ZeroGravityExitGravityScale` is replicated
* Local prediction on the owning client for zero-latency feel
* Server authoritative — client calls fire RPC to server

***

#### **Blueprint Usage**

**Minimal Flow — Gravity Field**

1. Place `BP_GravityField` in level
2. Set `ZeroGravityExitGravityScale` on the field
3. Bind overlap events on `OverlapMesh`
4. Call `ApplyEnterZeroGravity()` from whichever overlap event you want to trigger zero gravity — Begin or End
5. To exit, simply call whichever gravity mode Apply function you want to transition to — `ExitZeroGravity` is called automatically inside every Apply function, no explicit exit call needed

**Minimal Flow — Direct Component Call**

1. Get `GravityMovementComponent` from character
2. Call `EnterZeroGravity()` from a server function
3. Call `ExitZeroGravity(GravityScale)` when ready to restore gravity

***

#### **Configuration Properties**

```
bZeroGravityActive              // Read-only runtime state — true when in zero gravity
bExternalFlyingActive           // Set true to prevent zero gravity from overriding your flying mode
ZeroGravityExitGravityScale     // GravityScale restored on exit (default: 1.0)
```

***

#### **Debug Visualization**

* Debug widget correctly displays Zero Gravity as the active mode when `bShowVisualDebugs` is enabled

***

#### **Summary**

* Zero Gravity disables all surface probes and gravity rotation
* Character enters `MOVE_Flying` with `GravityScale` 0
* Fully replicated with local prediction
* `ExitZeroGravity` is idempotent — safe to call from any overlap unconditionally
* Clean integration with custom flying setups via `bExternalFlyingActive`
* `ZeroGravityExitGravityScale` controls gravity restoration on exit
* Automatically exited when any other gravity mode is applied via the Gravity Field


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://replicated-gravity.gitbook.io/replicated-gravity-docs/getting-started/setup-guides-and-tutorials/zero-gravity-usage-and-setup-guide.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
