UActorComponent::RecreatePhysicsState
#include "Components/ActorComponent.h"
Access: public
Description
Immediately destroys and recreates the physics state for this component. Use when physics properties have changed in a way that requires rebuilding the physics body from scratch.
Caveats & Gotchas
- • This is synchronous and expensive — it destroys the existing physics body, waits for it to be removed from the physics scene, then creates a new one. Avoid calling it every frame.
- • Accumulated velocity, angular momentum, and contact constraints are lost when the physics body is destroyed; use SetPhysicsLinearVelocity / SetPhysicsAngularVelocityInRadians after recreation if you need to restore them.
- • If the component's physics state is not currently created (IsPhysicsStateCreated() returns false), this is a no-op.
Signature
ENGINE_API void RecreatePhysicsState(); Return Type
void Example
Recreate physics after changing collision shape at runtime C++
void UMyCollisionComponent::SetCollisionRadius(float NewRadius)
{
CollisionRadius = NewRadius;
// Changing the shape requires a full physics state rebuild
RecreatePhysicsState();
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?