p.Chaos.Suspension.SlopeSpeedThreshold

p.Chaos.Suspension.SlopeSpeedThreshold

#Overview

name: p.Chaos.Suspension.SlopeSpeedThreshold

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.Suspension.SlopeSpeedThreshold is to control the anti-slide mechanism for vehicles on slopes in the Chaos physics system of Unreal Engine 5. It specifically defines the speed threshold below which the anti-slide mechanism is fully employed.

This setting variable is primarily used in the Chaos physics system, which is part of Unreal Engine’s experimental physics simulation module. It’s specifically utilized in the suspension constraints for vehicles.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be adjusted at runtime through the console. Its default value is 1.0f, measured in miles per hour (MPH).

This variable interacts closely with two other variables:

  1. Chaos_Suspension_SlopeThreshold: Defines the slope angle threshold for activating the anti-slide mechanism.
  2. Chaos_Suspension_SlopeSpeedBlendThreshold: Defines the speed at which the anti-slide mechanism starts to blend out.

Developers must be aware that this variable is crucial for fine-tuning vehicle behavior on slopes. It’s part of a system that prevents vehicles from sliding down steep inclines at low speeds, which can greatly improve the realism and controllability of vehicles in the game.

Best practices when using this variable include:

  1. Adjusting it in conjunction with the other related variables for a balanced vehicle behavior.
  2. Testing thoroughly with various slopes and vehicle types to ensure desired behavior across different scenarios.
  3. Considering performance implications, as very low values might increase physics calculations.

Regarding the associated variable Chaos_Suspension_SlopeSpeedThreshold:

This is the actual float variable that stores the value set by the console variable. It’s used directly in the physics calculations within the FPBDSuspensionConstraints::ApplySingle function.

The purpose of Chaos_Suspension_SlopeSpeedThreshold is the same as p.Chaos.Suspension.SlopeSpeedThreshold - it defines the speed below which the anti-slide mechanism is fully employed.

This variable is used in the Chaos physics system, specifically in the suspension constraints calculations.

Its value is set by the console variable and can be modified at runtime.

Developers should be aware that this variable is used in actual physics calculations after being converted from MPH to cm/s. Any changes to this variable will directly affect vehicle behavior at low speeds on slopes.

Best practices include carefully tuning this value in conjunction with related variables to achieve the desired vehicle behavior, and thoroughly testing any changes across various scenarios to ensure consistent and realistic vehicle performance.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDSuspensionConstraints.cpp:24

Scope: file

Source code excerpt:


float Chaos_Suspension_SlopeSpeedThreshold = 1.0f; // MPH
FAutoConsoleVariableRef CVarChaosSuspensionSlopeSpeedThreshold(TEXT("p.Chaos.Suspension.SlopeSpeedThreshold"), Chaos_Suspension_SlopeSpeedThreshold, TEXT("Speed below which the anti-slide on slope mechanism is fully employed"));

float Chaos_Suspension_SlopeSpeedBlendThreshold = 10.0f; // MPH
FAutoConsoleVariableRef CVarChaosSuspensionSlopeSpeedBlendThreshold(TEXT("p.Chaos.Suspension.SlopeSpeedBlendThreshold"), Chaos_Suspension_SlopeSpeedBlendThreshold, TEXT("Speed below which the anti-slide on slope blend mechanism starts"));

#if CHAOS_DEBUG_DRAW
bool bChaos_Suspension_DebugDraw_Hardstop = false;

#Associated Variable and Callsites

This variable is associated with another variable named Chaos_Suspension_SlopeSpeedThreshold. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDSuspensionConstraints.cpp:23

Scope: file

Source code excerpt:

FAutoConsoleVariableRef CVarChaosSuspensionSlopeThreshold(TEXT("p.Chaos.Suspension.SlopeThreshold"), Chaos_Suspension_SlopeThreshold, TEXT("Slope threshold below which the anti-slide on slope mechanism is employed, value = Cos(AlopeAngle), i.e. for 50 degree slope = 0.6428, 30 degree slope = 0.866"));

float Chaos_Suspension_SlopeSpeedThreshold = 1.0f; // MPH
FAutoConsoleVariableRef CVarChaosSuspensionSlopeSpeedThreshold(TEXT("p.Chaos.Suspension.SlopeSpeedThreshold"), Chaos_Suspension_SlopeSpeedThreshold, TEXT("Speed below which the anti-slide on slope mechanism is fully employed"));

float Chaos_Suspension_SlopeSpeedBlendThreshold = 10.0f; // MPH
FAutoConsoleVariableRef CVarChaosSuspensionSlopeSpeedBlendThreshold(TEXT("p.Chaos.Suspension.SlopeSpeedBlendThreshold"), Chaos_Suspension_SlopeSpeedBlendThreshold, TEXT("Speed below which the anti-slide on slope blend mechanism starts"));

#if CHAOS_DEBUG_DRAW
bool bChaos_Suspension_DebugDraw_Hardstop = false;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDSuspensionConstraints.cpp:382

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDSuspensionConstraints::ApplySingle

Source code excerpt:


			const float MPHToCmS = 100000.f / 2236.94185f;
			const float SpeedThreshold = Chaos_Suspension_SlopeSpeedThreshold * MPHToCmS;
			const float SpeedBlendThreshold = Chaos_Suspension_SlopeSpeedBlendThreshold * MPHToCmS;

			// Ingeniously blends the surface normal at low speeds to stop vehicles sliding slowly down steep slopes
			if (SurfaceNormal.Z > Chaos_Suspension_SlopeThreshold)
			{
				if (Body.V().SquaredLength() < (SpeedThreshold * SpeedThreshold))