p.PreventNonVerticalOrientationBlock

p.PreventNonVerticalOrientationBlock

#Overview

name: p.PreventNonVerticalOrientationBlock

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.PreventNonVerticalOrientationBlock is to control the character’s orientation in the Unreal Engine’s character movement system. Specifically, it allows a character that’s supposed to remain vertical to snap to a vertical orientation even if RotationRate settings would normally block it.

This setting variable is primarily used by the Character Movement Component, which is part of Unreal Engine’s gameplay framework. It’s a crucial part of the engine’s character movement and physics system.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 (enabled) in the CharacterMovementComponent.cpp file.

The associated variable bPreventNonVerticalOrientationBlock interacts directly with p.PreventNonVerticalOrientationBlock. They share the same value, with bPreventNonVerticalOrientationBlock being the actual variable used in the code logic.

Developers must be aware that this variable can override the normal rotation behavior of characters. When enabled, it allows characters to snap to a vertical orientation even when the RotationRate settings would normally prevent this. This can be particularly important for gameplay mechanics where characters need to maintain a specific orientation.

Best practices when using this variable include:

  1. Understanding its interaction with the RotationRate and ShouldRemainVertical functions.
  2. Testing thoroughly to ensure the desired character movement behavior is achieved.
  3. Consider gameplay implications, as this can affect how characters interact with the environment and other game elements.

Regarding the associated variable bPreventNonVerticalOrientationBlock:

The purpose of bPreventNonVerticalOrientationBlock is to serve as the actual boolean flag used in the character movement logic to determine whether the vertical orientation snapping should occur.

This variable is used within the UCharacterMovementComponent::PhysicsRotation function. When enabled and the character wants to be vertical (bWantsToBeVertical is true), it overrides the non-yaw rotation rates to allow the character to snap upright.

The value of this variable is set by the console variable system, mirroring the value of p.PreventNonVerticalOrientationBlock.

Developers should be aware that this variable directly affects the physics rotation calculations for characters. When enabled, it can significantly alter how characters rotate, especially in situations where maintaining a vertical orientation is crucial.

Best practices for using bPreventNonVerticalOrientationBlock include:

  1. Ensuring it’s used in conjunction with proper character setup, particularly the ShouldRemainVertical function.
  2. Monitoring its performance impact, as it may affect physics calculations.
  3. Using it judiciously, as it can create unrealistic movement if not properly balanced with other movement parameters.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:313

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

	static int32 bPreventNonVerticalOrientationBlock = 1;
	FAutoConsoleVariableRef CVarPreventNonVerticalOrientationBlock(
		TEXT("p.PreventNonVerticalOrientationBlock"),
		bPreventNonVerticalOrientationBlock,
		TEXT("When enabled, this allows a character that's supposed to remain vertical to snap to a vertical orientation even if RotationRate settings would block it. See @ShouldRemainVertical and @RotationRate."),
		ECVF_Default);

	static bool bDeferCharacterMeshMovement = false;
	FAutoConsoleVariableRef CVarDeferCharacterMeshMovement(

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:311

Scope (from outer to inner):

file
namespace    CharacterMovementCVars

Source code excerpt:

		ECVF_Default);

	static int32 bPreventNonVerticalOrientationBlock = 1;
	FAutoConsoleVariableRef CVarPreventNonVerticalOrientationBlock(
		TEXT("p.PreventNonVerticalOrientationBlock"),
		bPreventNonVerticalOrientationBlock,
		TEXT("When enabled, this allows a character that's supposed to remain vertical to snap to a vertical orientation even if RotationRate settings would block it. See @ShouldRemainVertical and @RotationRate."),
		ECVF_Default);

	static bool bDeferCharacterMeshMovement = false;
	FAutoConsoleVariableRef CVarDeferCharacterMeshMovement(
		TEXT("p.DeferCharacterMeshMovement"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Components/CharacterMovementComponent.cpp:6352

Scope (from outer to inner):

file
function     void UCharacterMovementComponent::PhysicsRotation

Source code excerpt:

	{
		// If we'd be prevented from becoming vertical, override the non-yaw rotation rates to allow the character to snap upright
		if (CharacterMovementCVars::bPreventNonVerticalOrientationBlock && bWantsToBeVertical)
		{
			if (FMath::IsNearlyZero(DeltaRot.Pitch))
			{
				DeltaRot.Pitch = 360.0;
			}
			if (FMath::IsNearlyZero(DeltaRot.Roll))