UPrimitiveComponent::SetSimulatePhysics
#include "Components/PrimitiveComponent.h"
Access: public
Specifiers: virtual
Description
Enables or disables physics simulation on the component. When enabled, the component is driven by the physics engine rather than by transform operations.
Signature
virtual void SetSimulatePhysics(bool bSimulate) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| bSimulate | bool | True to enable physics simulation, false to disable. | — |
Return Type
void Caveats & Gotchas
- • Enabling physics simulation on the root component detaches it from its parent's transform control — SetActorLocation will have no effect while simulating. Use AddForce/AddImpulse to move simulated components.
- • The component must have a physics body (UBodySetup) for simulation to work. Static meshes without collision will not simulate.
- • Enabling simulation automatically sets collision to QueryAndPhysics if it was set to NoCollision. This can cause unexpected overlap events.
Example
Drop a pickup on player death C++
void APickup::OnOwnerDied()
{
DetachFromActor(FDetachmentTransformRules::KeepWorldTransform);
MeshComponent->SetSimulatePhysics(true);
MeshComponent->AddImpulse(FVector(0, 0, 300.0f), NAME_None, true);
} See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?