# Vehicle Template Integration

#### **Install Plugin**

1. Find the **Replicated Gravity** plugin in your Fab Library.
2. Install to your preferred engine.
3. Enable the plugin in **Edit > Plugins**.
4. Restart the editor.

#### **Replace VehicleMovementComponent**

1. Open your **Vehicle Blueprint** (inherits from `WheeledVehiclePawn`).
2. In the **Components** list (Left side), select your `ChaosWheeledVehicleMovementComponent`.
3. In the **Details** panel (Right side), change the **Component Class** to `GravityVehicleMovementComponent`.
4. Compile and save your vehicle.

#### **Choose a Gravity Mode and Parameters**

Vehicles support Directional, Planetary, and Zero Gravity modes.

**Directional Gravity (Classic Down or Any Vector)**

* In your vehicle:
  * Select your `GravityVehicleMovementComponent`.
  * In the **Details** panel, locate the **Gravity Vehicle | Startup** category.
  * Enable `bUseStartupGravityOverride`.
  * Set `StartupGravityMode` = **Directional**.
  * Set `StartupGravityDirection` = your normalized direction (e.g., `0, 0, -1`).

**Planetary Gravity (Attraction to a Point)**

* In your vehicle:
  * Select your `GravityVehicleMovementComponent`.
  * In the **Details** panel, locate the **Gravity Vehicle | Startup** category.
  * Enable `bUseStartupGravityOverride`.
  * Set `StartupGravityMode` = **Planetary**.
  * Set `StartupGravityCenter` = desired world-space point (e.g., level origin).

**Zero Gravity**

* Zero Gravity is supported, but for most vehicle setups it should be applied at runtime through a gravity field or Blueprint logic, not as the default startup mode.

#### **Setup Vehicle Controller & UI**

**Re-parent Vehicle Controller**

1. Open your **Vehicle Player Controller** (e.g., `BP_VehicleAdvPlayerController`).
2. Go to **File > Reparent Blueprint**.
3. Search for and choose `GravityVehicleController`.
4. In the **Details** panel, configure:
   * **Vehicle UI Class**: Select your vehicle HUD widget.
   * **Default Mapping Contexts**: Add your Enhanced Input mappings.
   * **Use Steering Wheel Controls**: Enable if using steering wheel hardware.

#### **UI Integration**

* Your HUD widget should inherit from `GravityVehicleUI`, implement `IGravityVehicleDisplayInterface`, or provide compatible speed and gear update functions.
* If using `GravityVehicleUI`, use the `OnSpeedUpdate` and `OnGearUpdate` events to drive your UI elements.

#### **Tuning and Debugging**

**Ground Hold System:**

Used to keep vehicles planted on curved surfaces (planets, loops) at high speeds.

* `GroundHoldDownforceCoefficient`: Scales the extra inward acceleration.
* `FrontGroundHoldOffsetCm`: Moves the ground-hold torque point forward from the center of mass. Lower values reduce nose-down behavior.

**Dynamic Up-Alignment:**

Smoothly rotates the vehicle to match the local gravity vector.

* `bAlignVehicleUpToGravity`: Toggle the alignment system.
* `GravityAlignmentStiffness`: How fast the vehicle rotates to match gravity.
* `GravityAlignmentDamping`: Reduces overshoot and wobbling during transitions.

**Gravity-Aware Sleep:**

Prevents vehicles from sliding or jittering when parked on non-Z-up slopes.

* `bUseGravityAwareSleep`: Enable custom sleep logic.
* `GravityAwareControlInputWakeTolerance`: Prevents minor stick drift from waking the vehicle.

#### **Advanced Features**

**Iris Replication:**

The `GravityVehicleMovementComponent` is Iris-ready. Ensure your project has the Iris plugin enabled for high-performance networking support.

#### **World Gravity Policy**

* `bDisableWorldGravityWhenCustomGravityActive`: Automatically toggles the engine's default gravity to prevent double-force issues when custom gravity is engaged.

#### **Summary**

Your vehicle is now ready for:

* **Arbitrary gravity orientations** (planets, vertical tracks).
* **Networked authority** with server-reliable state transitions.
* **Specialized handling** for high-speed curved surface navigation.
* **Integrated UI and Input** management via the `GravityVehicleController`.


---

# 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/vehicle-template-integration.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.
