Navigation
API > API/Plugins > API/Plugins/PhysicsControl
Inheritance Hierarchy
- USceneComponent
- UPhysicsControlComponent
References
| Module | PhysicsControl |
| Header | /Engine/Plugins/Experimental/PhysicsControl/Source/PhysicsControl/Public/PhysicsControlComponent.h |
| Include | #include "PhysicsControlComponent.h" |
Syntax
UCLASS (Meta=(BlueprintSpawnableComponent), ClassGroup=Physics, Experimental)
class UPhysicsControlComponent : public USceneComponent
Remarks
This is the main Physics Control Component class which manages Controls and Body Modifiers associated with one or more static or skeletal meshes. You can add this as a component to an actor containing a mesh and then use it to create, configure and destroy Controls/Body Modifiers:
Controls are used to control one physics body relative to another (or the world). These controls are done through physical spring/damper drives.
Body Modifiers are used to update the most important physical properties of physics bodies such as whether they are simulated vs kinematic, or whether they experience gravity.
Note that Controls and Body Modifiers are given names (which are predictable). These names can then be stored (perhaps in arrays) to make it easy to quickly change multiple Controls/Body Modifiers.
Variables
| Type | Name | Description | |
|---|---|---|---|
| TMap< FName, FPhysicsBodyModifierRecord > | BodyModifierRecords | ||
| bool | bShowDebugBodyModifierList | Display all the body modifiers and their basic properties when this component is selected | |
| bool | bShowDebugControlList | Display all the controls and their basic properties when this component is selected | |
| bool | bShowDebugVisualization | Visualize the controls when this component is selected | |
| bool | bWarnAboutInvalidNames | Warn if an an invalid control or body modifier name is used. | |
| TMap< TWeakObjectPtr< USkeletalMeshComponent >, UE::PhysicsControl::FPhysicsControlPoseData > | CachedPoseDatas | Cached transforms from each skeletal mesh we're working with. | |
| TMap< FName, FPhysicsControlRecord > | ControlRecords | ||
| FGraphTraversalCounter | CurrentUpdateCounter | Update counter - incremented every tick, and used to check whether previous targets etc are valid when calculating velocities. | |
| FString | DebugBodyModifierDetailFilter | Display detailed info for body modifiers containing this string (if non-empty) when this component is selected | |
| FString | DebugControlDetailFilter | Display detailed info for controls containing this string (if non-empty) when this component is selected | |
| int32 | MaxNumControlsOrModifiersPerName | Upper limit on the number of controls or modifiers that will be created using the same name (which will get a numerical postfix). | |
| TMap< TWeakObjectPtr< USkeletalMeshComponent >, FModifiedSkeletalMeshData > | ModifiedSkeletalMeshDatas | Track which skeletons have been affected by a body modifier - some settings get overridden and then need to be restored when the last body modifier is destroyed. | |
| FPhysicsControlNameRecords | NameRecords | Keep track of the names of everything we have created. | |
| TSoftObjectPtr< UPhysicsControlAsset > | PhysicsControlAsset | Optional PhysicsControlAsset to use. | |
| float | TeleportDistanceThreshold | If the component moves by more than this distance then it is treated as a teleport, which prevents velocities being used for a frame. | |
| float | TeleportRotationThreshold | If the component rotates by more than this angle (in degrees) then it is treated as a teleport, which prevents velocities being used for a frame. | |
| float | VelocityPredictionTime | The time used when "predicting" the target position/orientation. | |
| float | VisualizationSizeScale | Size of the gizmos etc used during visualization |
Constructors
| Type | Name | Description | |
|---|---|---|---|
UPhysicsControlComponent
(
const FObjectInitializer& ObjectInitializer |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | AddBodyModifiersToSet
(
FPhysicsControlNames& NewSet, |
Adds BodyModifiers to a Set. | |
| void | AddBodyModifierToSet
(
FPhysicsControlNames& NewSet, |
Adds a BodyModifier to a Set. | |
| void | AddControlsToSet
(
FPhysicsControlNames& NewSet, |
Adds Controls to a Set. | |
| void | AddControlToSet
(
FPhysicsControlNames& NewSet, |
Adds a Control to a Set. | |
| void | AddSkeletalMeshReferenceForCaching
(
USkeletalMeshComponent* SkeletalMeshComponent |
Starts caching skeletal mesh poses, and registers for a tick pre-requisite | |
| void | AddSkeletalMeshReferenceForModifier
(
USkeletalMeshComponent* SkeletalMeshComponent |
Records that a modifier is working with the skeletal mesh and stores original data if necessary | |
| void | ApplyBodyModifier
(
FPhysicsBodyModifierRecord& BodyModifier |
Updates the body based on the modifier | |
| void | ApplyControl
(
FPhysicsControlRecord& Record |
Update the constraint based on the record. | |
| void | ApplyControlAndModifierUpdates
(
const FPhysicsControlControlAndModifierUpdates& ControlAndModifierUpdates |
Applies the updates to controls and body modifiers | |
| bool | ApplyControlStrengths
(
FPhysicsControlRecord& Record, |
Updates the constraint strengths. | |
| void | ApplyKinematicTarget
(
const FPhysicsBodyModifierRecord& BodyModifier |
This will set the kinematic target for the appropriate body based on the weighted target position and orientation (and whether any were found) for any controls that are related to the body modifier. | |
| void | BeginDestroy () |
||
| void | CalculateControlTargetData
(
FTransform& OutTargetTM, |
Calculates the Target TM and velocities that will get passed to the constraint - so this is a target that is defined in the space of the parent body (or in world space, if it doesn't exist). | |
| FName | CreateBodyModifier
(
UPrimitiveComponent* Component, |
Creates a new body modifier for mesh components | |
| TMap< FName, FPhysicsControlNames > | CreateBodyModifiersFromLimbBones
(
FPhysicsControlNames& AllBodyModifiers, |
Creates a collection of controls controlling a skeletal mesh, grouped together in limbs | |
| TArray< FName > | CreateBodyModifiersFromSkeletalMeshBelow
(
USkeletalMeshComponent* SkeletalMeshComponent, |
Creates new body modifiers for skeletal mesh components | |
| FName | CreateControl
(
UPrimitiveComponent* ParentComponent, |
Creates a new control for mesh components | |
| bool | CreateControlsAndBodyModifiersFromLimbBones
(
FPhysicsControlNames& AllWorldSpaceControls, |
Creates a collections of controls and body modifiers for a character, based on the description passed in. | |
| bool | CreateControlsAndBodyModifiersFromPhysicsControlAsset
(
USkeletalMeshComponent* SkeletalMeshComponent, |
This uses the control profile asset (that should have already been assigned in our data) to create controls and body modifiers. | |
| TMap< FName, FPhysicsControlNames > | CreateControlsFromLimbBones
(
FPhysicsControlNames& AllControls, |
Creates a collection of controls controlling a skeletal mesh, grouped together in limbs | |
| TMap< FName, FPhysicsControlNames > | CreateControlsFromLimbBonesAndConstraintProfile
(
FPhysicsControlNames& AllControls, |
Creates a collection of ParentSpace controls controlling a skeletal mesh, grouped together in limbs, initializing them with a constraint profile | |
| TArray< FName > | CreateControlsFromSkeletalMesh
(
USkeletalMeshComponent* SkeletalMeshComponent, |
Creates a collection of controls controlling a skeletal mesh | |
| TArray< FName > | CreateControlsFromSkeletalMeshAndConstraintProfile
(
USkeletalMeshComponent* SkeletalMeshComponent, |
Creates a collection of ParentSpace controls controlling a skeletal mesh, initializing them with a constraint profile | |
| TArray< FName > | CreateControlsFromSkeletalMeshAndConstraintProfileBelow
(
USkeletalMeshComponent* SkeletalMeshComponent, |
Creates a collection of ParentSpace controls controlling a skeletal mesh, initializing them with a constraint profile | |
| TArray< FName > | CreateControlsFromSkeletalMeshBelow
(
USkeletalMeshComponent* SkeletalMeshComponent, |
Creates a collection of controls controlling a skeletal mesh | |
| bool | CreateNamedBodyModifier
(
const FName Name, |
Creates a new body modifier for mesh components | |
| bool | CreateNamedControl
(
FName Name, |
Creates a new control for mesh components | |
| void | DebugDraw
(
FPrimitiveDrawInterface* PDI |
Used by the component visualizer. | |
| void | DebugDrawControl
(
FPrimitiveDrawInterface* PDI, |
||
| void | Destroys all controls and body modifiers | ||
| bool | DestroyBodyModifier
(
const FName Name |
Destroys a BodyModifier | |
| bool | DestroyBodyModifier
(
const FName Name, |
Destroys the modifier. It will optionally be removed from the array of records too | |
| void | DestroyBodyModifiers
(
const TArray< FName >& Names |
Destroys BodyModifiers | |
| void | DestroyBodyModifiersInSet
(
const FName Set |
Destroys BodyModifiers | |
| bool | DestroyControl
(
const FName Name |
Destroys a control | |
| bool | DestroyControl
(
const FName Name, |
Destroys the control. It will optionally be removed from the array of records too | |
| void | DestroyControls
(
const TArray< FName >& Names |
Destroys all controls | |
| void | DestroyControlsInSet
(
const FName Set |
Destroys all controls in a set | |
| void | Terminates everything we have made in physics. | ||
| const FPhysicsBodyModifierRecord * | FindBodyModifierRecord
(
const FName Name |
||
| FPhysicsBodyModifierRecord * | FindBodyModifierRecord
(
const FName Name |
Retrieves the body modifier for the name. | |
| const FPhysicsControl * | FindControl
(
const FName Name |
||
| FPhysicsControl * | FindControl
(
const FName Name |
Retrieves the control for the name. Returns a null pointer if the name cannot be found | |
| FPhysicsControlRecord * | FindControlRecord
(
const FName Name |
Retrieves the control record for the name. Returns a null pointer if the name cannot be found | |
| const FPhysicsControlRecord * | FindControlRecord
(
const FName Name |
||
| const TArray< FName > & | Returns a reference to all the body modifier names that have been created. | ||
| const TArray< FName > & | Returns a reference to all the control names that have been created. | ||
| bool | GetBodyModifierExists
(
const FName Name |
Indicates if a body modifier with the name exists (doesn't produce a warning if it doesn't) | |
| const TArray< FName > & | GetBodyModifierNamesInSet
(
const FName Set |
Returns a reference to all the body modifier names that have been created and are in the specified set, which could be a limb, or a subsequently created set. | |
| bool | GetBoneData
(
UE::PhysicsControl::FBoneData& OutBoneData, |
Retrieves the bone data for the specified bone given the skeletal mesh component. | |
| FRotator | GetCachedBoneOrientation
(
const USkeletalMeshComponent* SkeletalMeshComponent, |
Gets the orientation of the requested bone that will be used as a target (in world space). | |
| TArray< FRotator > | GetCachedBoneOrientations
(
const USkeletalMeshComponent* SkeletalMeshComponent, |
Gets the orientations of the requested bones that will be used as targets (in world space). | |
| FVector | GetCachedBonePosition
(
const USkeletalMeshComponent* SkeletalMeshComponent, |
Gets the position of the requested bone that will be used as a target (in world space). | |
| TArray< FVector > | GetCachedBonePositions
(
const USkeletalMeshComponent* SkeletalMeshComponent, |
Gets the positions of the requested bones that will be used as targets (in world space). | |
| FTransform | GetCachedBoneTransform
(
const USkeletalMeshComponent* SkeletalMeshComponent, |
Gets the transforms of the requested bone that will be used as a target (in world space). | |
| TArray< FTransform > | GetCachedBoneTransforms
(
const USkeletalMeshComponent* SkeletalMeshComponent, |
Gets the transforms of the requested bones that will be used as targets (in world space). | |
| bool | GetControlData
(
const FName Name, |
||
| bool | GetControlEnabled
(
const FName Name |
||
| bool | GetControlExists
(
const FName Name |
Indicates if a control with the name exists (doesn't produce a warning if it doesn't) | |
| bool | GetControlMultiplier
(
const FName Name, |
||
| const TArray< FName > & | GetControlNamesInSet
(
const FName Set |
Returns a reference to all the control names that have been created and are in the specified set, which could be a limb, or a subsequently created set. | |
| bool | GetControlTarget
(
const FName Name, |
||
| TMap< FName, FPhysicsControlLimbBones > | GetLimbBonesFromSkeletalMesh
(
USkeletalMeshComponent* SkeletalMeshComponent, |
Calculates which bones belong to which limb in a skeletal mesh | |
| bool | GetModifiableBoneData
(
UE::PhysicsControl::FBoneData*& OutBoneData, |
Retrieves the bone data for the specified bone given the skeletal mesh component, for modification | |
| TArray< FName > | GetSetsContainingBodyModifier
(
const FName Control |
Returns the names of all sets containing the body modifier (may be empty - e.g. if it doesn't exist) | |
| TArray< FName > | GetSetsContainingControl
(
const FName Control |
Returns the names of all sets containing the control (may be empty - e.g. if it doesn't exist) | |
| void | |||
| bool | InvokeControlProfile
(
FName ProfileName |
Looks up the profile which should exist in the registered control profile asset, and invokes it. | |
| void | |||
| void | |||
| void | OnRegister () |
||
| bool | RemoveSkeletalMeshReferenceForCaching
(
USkeletalMeshComponent* SkeletalMeshComponent |
Stops caching skeletal mesh poses (if this is the last one), and deregisters for a tick pre-requisite. | |
| bool | RemoveSkeletalMeshReferenceForModifier
(
USkeletalMeshComponent* SkeletalMeshComponent |
Records that a modifier has stopped working with the skeletal mesh and restores original data if necessary. | |
| void | ResetBodyModifiersInSetToCachedBoneTransforms
(
const FName SetName, |
Calls ResetBodyModifierToCachedTarget for each of the body modifiers in the set | |
| void | ResetBodyModifiersToCachedBoneTransforms
(
const TArray< FName >& Names, |
Calls ResetBodyModifierToCachedTarget for each of the body modifiers | |
| bool | ResetBodyModifierToCachedBoneTransform
(
const FName Name, |
This flags the body associated with the modifier to set (using teleport) its position and velocity to the cached animation target. | |
| bool | ResetControlPoint
(
const FName Name |
Resets the control point to the center of mass of the mesh | |
| void | ResetControls
(
bool bKeepControlRecords |
Terminates the underlying physical constraints, resets our internal stored state for each control, and optionally deletes all record of the controls. | |
| void | ResetToCachedTarget
(
const FPhysicsBodyModifierRecord& BodyModifier |
Sets the body (simulated or kinematic) to have the position/velocity etc state that has been cached. | |
| bool | SetBodyModifierCollisionType
(
const FName Name, |
Sets the collision type for a body modifier | |
| bool | SetBodyModifierData
(
const FName Name, |
Modifies an existing Body Modifier Data | |
| void | SetBodyModifierDatas
(
const TArray< FName >& Names, |
Modifies existing Body Modifier Data | |
| void | SetBodyModifierDatasInSet
(
const FName Set, |
Modifies existing Body Modifier Data | |
| bool | SetBodyModifierGravityMultiplier
(
const FName Name, |
Sets the gravity multiplier for a body modifier | |
| bool | SetBodyModifierKinematicTarget
(
const FName Name, |
Sets the kinematic target transform for a body modifier. | |
| bool | SetBodyModifierMovementType
(
const FName Name, |
Sets the movement type for a body modifier | |
| bool | SetBodyModifierPhysicsBlendWeight
(
const FName Name, |
Sets the physics blend weight for a body modifier | |
| void | SetBodyModifiersCollisionType
(
const TArray< FName >& Names, |
Sets the collision type for body modifiers | |
| void | SetBodyModifiersGravityMultiplier
(
const TArray< FName >& Names, |
Sets the gravity multiplier for body modifiers | |
| void | SetBodyModifiersInSetCollisionType
(
const FName Set, |
Sets the collision type for body modifiers | |
| void | SetBodyModifiersInSetGravityMultiplier
(
const FName Set, |
Sets the gravity multiplier for body modifiers | |
| void | SetBodyModifiersInSetMovementType
(
const FName Set, |
Sets the movement type for body modifiers | |
| void | SetBodyModifiersInSetPhysicsBlendWeight
(
const FName Set, |
Sets the physics blend weight for body modifiers | |
| void | SetBodyModifiersInSetUpdateKinematicFromSimulation
(
const FName Set, |
Sets whether body modifiers should update kinematics from the simulation results | |
| void | SetBodyModifiersInSetUseSkeletalAnimation
(
const FName Set, |
Sets whether body modifiers should use skeletal animation for their kinematic targets | |
| void | SetBodyModifiersMovementType
(
const TArray< FName >& Names, |
Sets the movement type for body modifiers | |
| bool | SetBodyModifierSparseData
(
const FName Name, |
Modifies an existing Body Modifier Data | |
| void | SetBodyModifierSparseDatas
(
const TArray< FName >& Names, |
Modifies existing Body Modifier Data | |
| void | SetBodyModifierSparseDatasInSet
(
const FName Set, |
Modifies existing Body Modifier Data | |
| void | SetBodyModifiersPhysicsBlendWeight
(
const TArray< FName >& Names, |
Sets the physics blend weight for body modifiers | |
| void | SetBodyModifiersUpdateKinematicFromSimulation
(
const TArray< FName >& Names, |
Sets whether body modifiers should update kinematics from the simulation results | |
| void | SetBodyModifiersUseSkeletalAnimation
(
const TArray< FName >& Names, |
Sets whether body modifiers should use skeletal animation for their kinematic targets | |
| bool | SetBodyModifierUpdateKinematicFromSimulation
(
const FName Name, |
Sets whether a body modifier should update kinematics from the simulation results | |
| bool | SetBodyModifierUseSkeletalAnimation
(
const FName Name, |
Sets whether a body modifier should use skeletal animation for its kinematic targets | |
| bool | SetCachedBoneData
(
const USkeletalMeshComponent* SkeletalMeshComponent, |
This allows the caller to override the target that will have been calculated and cached at the start of the Physics Control Component update. | |
| void | This sets cached bone velocities to zero, by forgetting any previously used transform. | ||
| bool | SetControlAngularData
(
const FName Name, |
Modifies an existing control's angular data - i.e. the strengths etc of the control driving towards the target | |
| bool | SetControlData
(
const FName Name, |
Modifies an existing control data - i.e. the strengths etc of the control driving towards the target | |
| void | SetControlDatas
(
const TArray< FName >& Names, |
Modifies existing control data - i.e. the strengths etc of the controls driving towards the targets | |
| void | SetControlDatasInSet
(
const FName Set, |
Modifies existing control data - i.e. the strengths etc of the controls driving towards the targets | |
| bool | SetControlDisableCollision
(
const FName Name, |
||
| bool | SetControlEnabled
(
const FName Name, |
Activates or deactivates a control | |
| bool | SetControlLinearData
(
const FName Name, |
Modifies an existing control's linear data - i.e. the strengths etc of the control driving towards the target | |
| bool | SetControlMultiplier
(
const FName Name, |
Modifies an existing control data using the multipliers | |
| void | SetControlMultipliers
(
const TArray< FName >& Names, |
Modifies existing control data using the multipliers | |
| void | SetControlMultipliersInSet
(
const FName Set, |
Modifies existing control data using the multipliers | |
| bool | SetControlParent
(
const FName Name, |
Updates the parent object part of a control. | |
| void | SetControlParents
(
const TArray< FName >& Names, |
Updates the parent object part of controls. | |
| void | SetControlParentsInSet
(
const FName Set, |
||
| bool | SetControlPoint
(
const FName Name, |
Sets the point at which controls will "push" the child object. | |
| void | SetControlsDisableCollision
(
const TArray< FName >& Names, |
||
| void | SetControlsEnabled
(
const TArray< FName >& Names, |
Activates or deactivates controls | |
| void | SetControlsInSetDisableCollision
(
const FName Set, |
||
| void | SetControlsInSetEnabled
(
const FName Set, |
Activates or deactivates controls | |
| void | SetControlsInSetUseSkeletalAnimation
(
const FName Set, |
Sets whether or not the controls should use skeletal animation for the targets | |
| bool | SetControlSparseData
(
const FName Name, |
Modifies an existing control data - i.e. the strengths etc of the control driving towards the target | |
| void | SetControlSparseDatas
(
const TArray< FName >& Names, |
Modifies existing control data - i.e. the strengths etc of the controls driving towards the targets | |
| void | SetControlSparseDatasInSet
(
const FName Set, |
Modifies existing control data - i.e. the strengths etc of the controls driving towards the targets | |
| bool | SetControlSparseMultiplier
(
const FName Name, |
Modifies an existing control data using the multipliers | |
| void | SetControlSparseMultipliers
(
const TArray< FName >& Names, |
Modifies existing control data using the multipliers | |
| void | SetControlSparseMultipliersInSet
(
const FName Set, |
Modifies existing control data using the multipliers | |
| void | SetControlsUseSkeletalAnimation
(
const TArray< FName >& Names, |
Sets whether or not the controls should use skeletal animation for the targets | |
| bool | SetControlTarget
(
const FName Name, |
Modifies an existing control target - i.e. what it is driving towards, relative to the parent object | |
| bool | SetControlTargetOrientation
(
const FName Name, |
Modifies an existing control target - i.e. what it is driving towards, relative to the parent object | |
| void | SetControlTargetOrientations
(
const TArray< FName >& Names, |
Calls SetControlTargetOrientation for each of the control names | |
| bool | SetControlTargetOrientationsFromArray
(
const TArray< FName >& Names, |
Calls SetControlTargetPosition for each element of the control names and positions. | |
| void | SetControlTargetOrientationsInSet
(
const FName SetName, |
Calls SetControlTargetOrientation for each of the controls in the set | |
| bool | SetControlTargetPoses
(
const FName Name, |
Calculates and sets an existing control target. | |
| bool | SetControlTargetPosition
(
const FName Name, |
Modifies an existing control target - i.e. what it is driving towards, relative to the parent object | |
| bool | SetControlTargetPositionAndOrientation
(
const FName Name, |
Modifies an existing control target - i.e. what it is driving towards, relative to the parent object | |
| void | SetControlTargetPositions
(
const TArray< FName >& Names, |
Calls SetControlTargetPosition for each of the control names | |
| void | SetControlTargetPositionsAndOrientations
(
const TArray< FName >& Names, |
Calls SetControlTargetPositionAndOrientation for each of the control names | |
| bool | SetControlTargetPositionsAndOrientationsFromArray
(
const TArray< FName >& Names, |
Calls SetControlTargetPositionAndOrientation for each element of the control names, positions and orientations. | |
| void | SetControlTargetPositionsAndOrientationsInSet
(
const FName SetName, |
Calls SetControlTargetPositionAndOrientation for each control in the set | |
| bool | SetControlTargetPositionsFromArray
(
const TArray< FName >& Names, |
Calls SetControlTargetPosition for each element of the control names and positions. | |
| void | SetControlTargetPositionsInSet
(
const FName SetName, |
Calls SetControlTargetPosition for each of the controls in the set | |
| void | SetControlTargets
(
const TArray< FName >& Names, |
Modifies existing control targets - i.e. what they are driving towards, relative to the parent objects | |
| void | SetControlTargetsInSet
(
const FName Set, |
Modifies existing control targets - i.e. what they are driving towards, relative to the parent objects | |
| bool | SetControlUseSkeletalAnimation
(
const FName Name, |
Sets whether or not the control should use skeletal animation for the targets | |
| bool | |||
| void | TickComponent
(
float DeltaTime, |
||
| void | UpdateCachedSkeletalBoneData
(
float DeltaTime |
Updates the world-space bone positions etc for each skeleton we're tracking | |
| void | UpdateControls
(
float DeltaTime |
Allows manual ticking so that your code can run in between updating the target caches and updating the controls and body modifiers. | |
| void | UpdateTargetCaches
(
float DeltaTime |
Allows manual ticking so that your code can run in between updating the target caches and updating the controls. |
Enums
| Type | Name | Description | |
|---|---|---|---|
| EDestroyBehavior | When destroying a control or modifier, the record will normally be removed, but it can be retained if you will subsequently update the records |