p.SimCollisionEnabled

p.SimCollisionEnabled

#Overview

name: p.SimCollisionEnabled

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.SimCollisionEnabled is to control whether simulation collision is used in the physics engine of Unreal Engine 5. This setting variable is primarily related to the physics simulation system.

Based on the details in the Callsites section, this variable is used in the Engine module, specifically within the PhysicsEngine subsystem. It’s referenced in the BodyInstance.cpp file, which handles physics body instances.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands. By default, it is set to 1, enabling simulation collision.

The associated variable SimCollisionEnabled interacts directly with p.SimCollisionEnabled. They share the same value and are used interchangeably in the code.

Developers must be aware that setting this variable to 0 will disable all simulation collision in the engine. This can have significant impacts on gameplay and physics interactions, so it should be used carefully.

Best practices when using this variable include:

  1. Only disable simulation collision if you have a specific reason to do so, as it’s a fundamental part of physics simulation.
  2. If you need to disable collision for specific objects, consider using other methods (like collision channels or object-specific settings) rather than this global setting.
  3. Be aware that changing this value at runtime may have immediate and potentially unexpected effects on all physics simulations in the game.

Regarding the associated variable SimCollisionEnabled: This is an integer variable that directly corresponds to p.SimCollisionEnabled. It’s used in the BuildBodyCollisionFlags function to determine whether to enable simulation collision for body instances. When SimCollisionEnabled is true (non-zero), and either probe collision or physics collision is enabled for a body, the function will set up the appropriate collision flags. Developers should be aware that modifying SimCollisionEnabled will have the same effect as modifying p.SimCollisionEnabled, affecting all physics simulations in the engine.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyInstance.cpp:4390

Scope: file

Source code excerpt:


int32 SimCollisionEnabled = 1;
FAutoConsoleVariableRef CVarSimCollisionEnabled(TEXT("p.SimCollisionEnabled"), SimCollisionEnabled, TEXT("If 0 no sim collision will be used"));

void FBodyInstance::BuildBodyCollisionFlags(FBodyCollisionFlags& OutFlags, ECollisionEnabled::Type UseCollisionEnabled, bool bUseComplexAsSimple)
{
	OutFlags.bEnableQueryCollision = false;
	OutFlags.bEnableSimCollisionSimple = false;
	OutFlags.bEnableSimCollisionComplex = false;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyInstance.cpp:4389

Scope: file

Source code excerpt:

}

int32 SimCollisionEnabled = 1;
FAutoConsoleVariableRef CVarSimCollisionEnabled(TEXT("p.SimCollisionEnabled"), SimCollisionEnabled, TEXT("If 0 no sim collision will be used"));

void FBodyInstance::BuildBodyCollisionFlags(FBodyCollisionFlags& OutFlags, ECollisionEnabled::Type UseCollisionEnabled, bool bUseComplexAsSimple)
{
	OutFlags.bEnableQueryCollision = false;
	OutFlags.bEnableSimCollisionSimple = false;
	OutFlags.bEnableSimCollisionComplex = false;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyInstance.cpp:4406

Scope (from outer to inner):

file
function     void FBodyInstance::BuildBodyCollisionFlags

Source code excerpt:

		// Sim collision
		const bool bProbe = CollisionEnabledHasProbe(UseCollisionEnabled);
		const bool bSimCollision = SimCollisionEnabled && (bProbe || CollisionEnabledHasPhysics(UseCollisionEnabled));

		// Enable sim collision
		if(bSimCollision)
		{
			// Objects marked as probes use sim collision, but don't actually have physical reactions
			OutFlags.bEnableProbeCollision = bProbe;