USpringArmComponent

This component tries to maintain its children at a fixed distance from the parent, but will retract the children if there is a collision, and spring back when there is no collision.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/GameFramework/SpringArmComponent.h

Include

#include "GameFramework/SpringArmComponent.h"

Syntax

class USpringArmComponent : public USceneComponent

Remarks

This component tries to maintain its children at a fixed distance from the parent, but will retract the children if there is a collision, and spring back when there is no collision.

Example: Use as a 'camera boom' to keep the follow camera for a player from colliding into the world.

Variables

Name Description

Public variable

uint32: 1

 

bDoCollisionTest

If true, do a collision test using ProbeChannel and ProbeSize to prevent camera clipping into level.

Public variable

uint32: 1

 

bDrawDebugLagMarkers

If true and camera location lag is enabled, draws markers at the camera target (in green) and the lagged position (in yellow).

Public variable

uint32: 1

 

bEnableCameraLag

If true, camera lags behind target position to smooth its movement.

Public variable

uint32: 1

 

bEnableCameraRotationLag

If true, camera lags behind target rotation to smooth its movement.

Public variable

uint32: 1

 

bInheritPitch

Should we inherit pitch from parent component. Does nothing if using Absolute Rotation.

Public variable

uint32: 1

 

bInheritRoll

Should we inherit roll from parent component. Does nothing if using Absolute Rotation.

Public variable

uint32: 1

 

bInheritYaw

Should we inherit yaw from parent component. Does nothing if using Absolute Rotation.

Public variable

bool

 

bIsCameraFixed

Temporary variables when applying Collision Test displacement to notify if its being applied and by how much

Public variable

uint32: 1

 

bUseCameraLagSubstepping

If bUseCameraLagSubstepping is true, sub-step camera damping so that it handles fluctuating frame rates well (though this comes at a cost).

Public variable

uint32: 1

 

bUsePawnControlRotation

If this component is placed on a pawn, should it use the view/control rotation of the pawn where possible? When disabled, the component will revert to using the stored RelativeRotation of the component.

Public variable

float

 

CameraLagMaxDistance

Max distance the camera target may lag behind the current location.

Public variable

float

 

CameraLagMaxTimeStep

Max time step used when sub-stepping camera lag.

Public variable

float

 

CameraLagSpeed

If bEnableCameraLag is true, controls how quickly camera reaches target position.

Public variable

float

 

CameraRotationLagSpeed

If bEnableCameraRotationLag is true, controls how quickly camera reaches target position.

Public variable

FVector

 

PreviousArmOrigin

Public variable

FVector

 

PreviousDesiredLoc

Temporary variables when using camera lag, to record previous camera position

Public variable

FRotator

 

PreviousDesiredRot

Temporary variable for lagging camera rotation, for previous rotation

Public variable

TEnumAsByte< EC...

 

ProbeChannel

Collision channel of the query probe (defaults to ECC_Camera)

Public variable

float

 

ProbeSize

How big should the query probe sphere be (in unreal units)

Protected variable

FVector

 

RelativeSocketLocation

Cached component-space socket location

Protected variable

FQuat

 

RelativeSocketRotation

Cached component-space socket rotation

Public variable

FVector

 

SocketOffset

Offset at end of spring arm; use this instead of the relative offset of the attached component to ensure the line trace works as desired

Public variable

float

 

TargetArmLength

Natural length of the spring arm when there are no collisions

Public variable

FVector

 

TargetOffset

Offset at start of spring, applied in world space.

Public variable

FVector

 

UnfixedCameraPosition

Constructors

Name Description

Public function

USpringArmComponent

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Protected function Virtual

FVector

 

BlendLocations

(
    const FVector& DesiredArmLocation,
    const FVector& TraceHitLocation,
    bool bHitSomething,
    float DeltaTime
)

This function allows subclasses to blend the trace hit location with the desired arm location; by default it returns bHitSomething ? TraceHitLocation : DesiredArmLocation

Public function Virtual Const

FRotator

 

GetDesiredRotation()

Returns the desired rotation for the spring arm, before the rotation constraints such as bInheritPitch etc are enforced.

Public function Const

FRotator

 

GetTargetRotation()

Get the target rotation we inherit, used as the base target for the boom rotation.

Public function Const

FVector

 

GetUnfixedCameraPosition()

Get the position where the camera should be without applying the Collision Test displacement

Public function Const

bool

 

IsCollisionFixApplied()

Is the Collision Test displacement being applied?

Protected function Virtual

void

 

UpdateDesiredArmLocation

(
    bool bDoTrace,
    bool bDoLocationLag,
    bool bDoRotationLag,
    float DeltaTime
)

Updates the desired arm location, calling BlendLocations to do the actual blending if a trace is done

Overridden from USceneComponent

Name Description

Public function Virtual Const

FTransform

 

GetSocketTransform

(
    FName InSocketName,
    ERelativeTransformSpace TransformSp...
)

Get world-space socket transform.

Public function Virtual Const

bool

 

HasAnySockets()

Returns true if this component has any sockets

Public function Virtual Const

void

 

QuerySupportedSockets

Get a list of sockets this component contains

Overridden from UActorComponent

Name Description

Public function Virtual

void

 

ApplyWorldOffset

(
    const FVector& InOffset,
    bool bWorldShift
)

Called by owner actor on position shifting Component should update all relevant data structures to reflect new actor location

Public function Virtual

void

 

OnRegister()

Called when a component is registered, after Scene is set, but before CreateRenderState_Concurrent or OnCreatePhysicsState are called.

Public function Virtual

void

 

TickComponent

(
    float DeltaTime,
    enum ELevelTick TickType,
    FActorComponentTickFunction* T...
)

Function called every frame on this ActorComponent.

Overridden from UObject

Name Description

Public function Virtual

void

 

PostLoad()

Do any object-specific cleanup required immediately after loading an object.

Constants

Name

Description

SocketName

The name of the socket at the end of the spring arm (looking back towards the spring arm origin)

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss