enable bGravityEnabled, bSimulatePhysics, and call WakeRigidBody on grab component's owning actor at BeginPlay() if bAffectPhysicsState is enabled
This commit is contained in:
@@ -135,4 +135,29 @@ USGGrabComponent::FImpl::~FImpl() = default;
|
||||
void USGGrabComponent::FImplDeleter::operator()(const FImpl* P) const
|
||||
{
|
||||
delete P;
|
||||
}
|
||||
|
||||
void USGGrabComponent::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
if (bAffectPhysicsState)
|
||||
{
|
||||
const AActor* OwnerActor{GetOwner()};
|
||||
if (!ensureAlwaysMsgf(IsValid(OwnerActor), TEXT("Invalid OwnerActor!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
UPrimitiveComponent* ActorRootComponent{Cast<UPrimitiveComponent>(OwnerActor->GetRootComponent())};
|
||||
if (!ensureAlwaysMsgf(IsValid(ActorRootComponent),
|
||||
TEXT("RootComponent is not a valid UPrimativeComponent!")))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ActorRootComponent->SetEnableGravity(true);
|
||||
ActorRootComponent->SetSimulatePhysics(true);
|
||||
ActorRootComponent->WakeRigidBody();
|
||||
}
|
||||
}
|
||||
@@ -196,4 +196,7 @@ public:
|
||||
{
|
||||
bAffectPhysicsState = bInAffectPhysicsState;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void BeginPlay() override;
|
||||
};
|
||||
Reference in New Issue
Block a user