I’m curious, why does this crash the editor when running :
void UGrabber::Grab()
{
auto InReach = GetFirstPhysicsBodyInReach();
if (InReach.GetActor()) {
PhysicsHandle->GrabComponent(
InReach.GetComponent(),
NAME_None,
InReach.GetActor()->GetOwner()->GetActorLocation(),
true
);
}
}
But this does not:
void UGrabber::Grab() {
auto HitResult = GetFirstPhysicsBodyInReach();
auto ComponentToGrab = HitResult.GetComponent();
auto ActorHit = HitResult.GetActor();
if (ActorHit)
{
PhysicsHandle->GrabComponent(
ComponentToGrab,
NAME_None,
ComponentToGrab->GetOwner()->GetActorLocation(),
true // allow rotation
);
}
}