InteractionDistance

InteractionDistance

#Overview

name: InteractionDistance

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 9 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of InteractionDistance is to define the maximum distance at which the component can interact with other objects or widgets in the game world. This setting variable is primarily used in the context of widget interaction and physics asset editing.

InteractionDistance is utilized by the following Unreal Engine subsystems and modules:

  1. XRCreativeFramework Plugin
  2. PhysicsAssetEditor
  3. UMG (Unreal Motion Graphics) system

The value of this variable is set in different places depending on the context:

  1. In the XRCreativeAvatar, it’s set to 50.0 units.
  2. In the PhysicsAssetEditor, it’s accessed through SharedData->EditorOptions->InteractionDistance.
  3. In the WidgetInteractionComponent, it’s initialized to 500 units but can be modified through the UPROPERTY system.

InteractionDistance interacts with other variables and systems, such as:

  1. It’s used in line trace calculations to determine hit results.
  2. In the PhysicsAssetEditor, it’s used to calculate SimGrabMinPush.
  3. In the WidgetInteractionComponent, it’s used to determine the end point of interaction rays.

Developers should be aware of the following when using this variable:

  1. The value affects the range of interaction, which can impact gameplay and user experience.
  2. Different systems may use different default values, so it’s important to set it appropriately for each use case.
  3. In VR or AR applications, this value may need to be adjusted to provide a natural feeling of interaction.

Best practices when using this variable include:

  1. Adjust the value based on the scale of your game world and the intended interaction range.
  2. Consider exposing this value as a configurable option for players to adjust based on their preferences.
  3. When using it in custom systems, ensure that the value is clamped to prevent unrealistic interaction distances.
  4. In editor tools, make sure the interaction distance is appropriate for the scale of the objects being edited.
  5. For widget interactions, consider the size of the UI elements and the expected viewing distance when setting this value.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:519, section: [/Script/UnrealEd.PhysicsAssetEditorOptions]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/XRCreativeFramework/Source/XRCreative/Private/XRCreativeAvatar.cpp:93

Scope (from outer to inner):

file
function     AXRCreativeAvatar::AXRCreativeAvatar

Source code excerpt:

	WidgetInteraction->bTickInEditor = true;
	WidgetInteraction->bShowDebug = false;
	WidgetInteraction->InteractionDistance = 50.0;
	
	ToolsComponent = CreateDefaultSubobject<UXRCreativeITFComponent>("ToolsComponent");
	ToolsComponent->bTickInEditor = true;
	ToolsComponent->SetPointerComponent(RightControllerPointer);

	BaseEyeHeight = 0.0f;

#Loc: <Workspace>/Engine/Source/Editor/PhysicsAssetEditor/Private/PhysicsAssetEditorEditMode.cpp:899

Scope (from outer to inner):

file
function     bool FPhysicsAssetEditorEditMode::SimMousePress

Source code excerpt:

	const FViewportClick Click(View, InViewportClient, EKeys::Invalid, IE_Released, Viewport->GetMouseX(), Viewport->GetMouseY());
	FHitResult Result(1.f);
	bool bHit = SharedData->EditorSkelComp->LineTraceComponent(Result, Click.GetOrigin(), Click.GetOrigin() + Click.GetDirection() * SharedData->EditorOptions->InteractionDistance, FCollisionQueryParams(NAME_None, true));

	SharedData->LastClickPos = Click.GetClickPos();
	SharedData->LastClickOrigin = Click.GetOrigin();
	SharedData->LastClickDirection = Click.GetDirection();
	SharedData->bLastClickHit = bHit;
	if (bHit)

#Loc: <Workspace>/Engine/Source/Editor/PhysicsAssetEditor/Private/PhysicsAssetEditorEditMode.cpp:940

Scope (from outer to inner):

file
function     bool FPhysicsAssetEditorEditMode::SimMousePress

Source code excerpt:

				FMatrix	InvViewMatrix = View->ViewMatrices.GetInvViewMatrix();

				SimGrabMinPush = SimMinHoldDistance - (Result.Time * SharedData->EditorOptions->InteractionDistance);

				SimGrabLocation = Result.Location;
				SimGrabX = InvViewMatrix.GetUnitAxis(EAxis::X);
				SimGrabY = InvViewMatrix.GetUnitAxis(EAxis::Y);
				SimGrabZ = InvViewMatrix.GetUnitAxis(EAxis::Z);
			}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Preferences/PhysicsAssetEditorOptions.h:101

Scope (from outer to inner):

file
class        class UPhysicsAssetEditorOptions : public UObject

Source code excerpt:

	/** Raycast distance when poking or grabbing */
	UPROPERTY(EditAnywhere, config, Category = Poking, meta = (ClampMin = 0))
	float InteractionDistance;

	/** Whether to draw constraints as points */
	UPROPERTY(config)
	uint32 bShowConstraintsAsPoints:1;

	/** Whether to highlight limits that have been violated */

#Loc: <Workspace>/Engine/Source/Runtime/UMG/Private/Components/WidgetInteractionComponent.cpp:24

Scope (from outer to inner):

file
function     UWidgetInteractionComponent::UWidgetInteractionComponent

Source code excerpt:

	, VirtualUserIndex(0)
	, PointerIndex(0)
	, InteractionDistance(500)
	, InteractionSource(EWidgetInteractionSource::World)
	, bEnableHitTesting(true)
	, bShowDebug(false)
	, DebugSphereLineThickness(2.f)
	, DebugLineThickness(1.f)
	, DebugColor(FLinearColor::Red)

#Loc: <Workspace>/Engine/Source/Runtime/UMG/Private/Components/WidgetInteractionComponent.cpp:149

Scope (from outer to inner):

file
function     UWidgetInteractionComponent::FWidgetTraceResult UWidgetInteractionComponent::PerformTrace

Source code excerpt:


			TraceResult.LineStartLocation = WorldLocation;
			TraceResult.LineEndLocation = WorldLocation + (WorldDirection * InteractionDistance);

			GetWorld()->LineTraceMultiByChannel(MultiHits, TraceResult.LineStartLocation, TraceResult.LineEndLocation, TraceChannel, Params);
			break;
		}
		case EWidgetInteractionSource::Mouse:
		case EWidgetInteractionSource::CenterScreen:

#Loc: <Workspace>/Engine/Source/Runtime/UMG/Private/Components/WidgetInteractionComponent.cpp:183

Scope (from outer to inner):

file
function     UWidgetInteractionComponent::FWidgetTraceResult UWidgetInteractionComponent::PerformTrace

Source code excerpt:

						{
							TraceResult.LineStartLocation = WorldOrigin;
							TraceResult.LineEndLocation = WorldOrigin + WorldDirection * InteractionDistance;

							GetWorld()->LineTraceMultiByChannel(MultiHits, TraceResult.LineStartLocation, TraceResult.LineEndLocation, TraceChannel, Params);
						}
					}
				}
				else if ( InteractionSource == EWidgetInteractionSource::CenterScreen )

#Loc: <Workspace>/Engine/Source/Runtime/UMG/Private/Components/WidgetInteractionComponent.cpp:198

Scope (from outer to inner):

file
function     UWidgetInteractionComponent::FWidgetTraceResult UWidgetInteractionComponent::PerformTrace

Source code excerpt:

					{
						TraceResult.LineStartLocation = WorldOrigin;
						TraceResult.LineEndLocation = WorldOrigin + WorldDirection * InteractionDistance;

						GetWorld()->LineTraceMultiByChannel(MultiHits, WorldOrigin, WorldOrigin + WorldDirection * InteractionDistance, TraceChannel, Params);
					}
				}
			}
			break;
		}
		case EWidgetInteractionSource::Custom:

#Loc: <Workspace>/Engine/Source/Runtime/UMG/Public/Components/WidgetInteractionComponent.h:219

Scope (from outer to inner):

file
class        class UWidgetInteractionComponent : public USceneComponent

Source code excerpt:

	 */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Interaction")
	float InteractionDistance;

	/**
	 * Should we project from the world location of the component?  If you set this to false, you'll
	 * need to call SetCustomHitResult(), and provide the result of a custom hit test form whatever
	 * location you wish.
	 */