UPrimitiveComponent::SetCollisionEnabled
#include "Components/PrimitiveComponent.h"
Access: public
Specifiers: virtual
Description
Sets the collision enabled state on the component. Controls whether the component participates in physics simulation and/or spatial queries (raycasts, overlaps).
Signature
virtual void SetCollisionEnabled(ECollisionEnabled::Type NewType) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| NewType | ECollisionEnabled::Type | The collision mode: NoCollision, QueryOnly, PhysicsOnly, or QueryAndPhysics. | — |
Return Type
void Caveats & Gotchas
- • QueryOnly disables physics (no forces/impulses affect the body) but still fires overlaps and blocks traces. PhysicsOnly is the reverse. QueryAndPhysics enables both.
- • NoCollision completely removes the body from the physics scene — more efficient than QueryOnly when neither queries nor physics are needed.
- • Does not override the collision profile's channel responses — it only controls whether collision is active at all. Use SetCollisionProfileName to change response channels.
Example
Disable collision during a spawn grace period C++
// Temporarily disable all collision during spawn invincibility
MeshComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);
FTimerHandle Handle;
GetWorldTimerManager().SetTimer(Handle, [this]()
{
MeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
}, 2.0f, false); See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?