UPrimitiveComponent::GetBodyInstance
#include "Components/PrimitiveComponent.h"
Access: public
Specifiers: virtualconst
Description
Returns the FBodyInstance for this component's physics body, providing direct access to low-level physics properties and operations.
Signature
virtual FBodyInstance* GetBodyInstance(FName BoneName = NAME_None, bool bGetWelded = true, int32 Index = INDEX_NONE) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| BoneName | FName | Bone name for skeletal mesh components. NAME_None for the root body. | NAME_None |
| bGetWelded | bool | If true, returns the welded parent body when this body is welded to another. | true |
Return Type
FBodyInstance* Caveats & Gotchas
- • Returns null if the component has no physics body (e.g. collision is disabled, or the mesh has no collision setup). Always null-check.
- • For most gameplay needs (apply force, set mass, etc.) the higher-level functions on UPrimitiveComponent are preferred over direct FBodyInstance access.
- • Modifying FBodyInstance directly bypasses UE's property replication — do not use in networked contexts where physics state must replicate.
Example
Set mass and linear damping directly C++
if (FBodyInstance* BI = MeshComponent->GetBodyInstance())
{
BI->SetMassOverride(50.0f);
BI->LinearDamping = 0.5f;
BI->AngularDamping = 1.0f;
BI->UpdateDampingProperties();
} Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?