Download

UPhysicsHandleComponent Crash the editor.

No one has answered me on the Answerhub, and yet this thing is driving me crazy.

Im using a Grabbing action for the player, it gives the ability to grab props and carry them wherever he wants.
I’ve been following the content example blueprint, which allows you to grab certain static meshes and Im translating it into C++.
The problem is that whenever I click to grab the static mesh, the game & editor crashes.

Here are the steps Im doing.

1.- bool Trace: This trace will trace a line and see if the hitting object has a specific tag. If true then…
2.- Grab Trace: Make the same trace, this time we will add a Physic Handler to the component that the trace did hit. ← This is where it crashes, the first trace is working nice.

Here is my .h


CollisionQueryParams TraceParams;
     UPhysicsHandleComponent* PhysicsHandle;
     UPrimitiveComponent* PhysicsObject;

and my .cpp with the constructor of the function to call it when the characters want to grab an object.


void ACharacter::GrabObject()
 {    
     FHitResult GC_OutHit(ForceInit);
     APlayerCameraManager* GPCM = UGameplayStatics::GetPlayerCameraManager(this, 0);
     TraceParams.bTraceComplex = true;
     TraceParams.AddIgnoredComponent(GetCapsuleComponent());
     if (GetWorld()->LineTraceSingle(GC_OutHit,
         GPCM->GetCameraLocation(),
         GPCM->GetCameraLocation() + (FVector(500.f) * FVector(GPCM->GetCameraRotation().Vector())),
         ECollisionChannel::ECC_PhysicsBody,
         TraceParams))
     {
         PH_Active = true;
         DrawDebugLine(GetWorld(),
             GPCM->GetCameraLocation(),
             GPCM->GetCameraLocation() + (FVector(500.f) * FVector(GPCM->GetCameraRotation().Vector())),
             FColor::Green,
             true,
             10.f,
             0,
             2.f);
         PhysicsObject = GC_OutHit.GetComponent();
         PhysicsObject->InitializeComponent();
         PhysicsHandle->LinearDamping = 200.f;
         PhysicsHandle->LinearStiffness = 750.f;
         PhysicsHandle->AngularDamping = 500.f;
         PhysicsHandle->AngularStiffness = 1500.f;
         PhysicsHandle->InterpolationSpeed = 50.f;
 
         PhysicsHandle->GrabComponent(PhysicsObject, GC_OutHit.BoneName, GC_OutHit.Location, true);
         PhysicsHandle->SetTargetLocation(GPCM->GetCameraLocation() + (FVector(500.f) * FVector(GPCM->GetCameraRotation().Vector())));
 
     }
     else
         PH_Active = false;
 
 }

The line where its crashing is in this: PhysicsHandle->GrabComponent(PhysicsObject, GC_OutHit.BoneName, GC_OutHit.Location, true); But If I remove it, then it crashes on this line:

PhysicsHandle->LinearDamping = 200.f;

Basically it crashes when I access any variable or function of the class, I included too the PhysicHandleComponent.h but it keeps failing, I just thinking I must initialize something before but I don’t know why. Thanks for the help.

Im using 4.7.3, Win8 64-bit

Please don’t do the same here.

Please somebody!

Someone pls!!!

Hey Georgespartan01-

As mentioned on the AnswerHub post you created (https://answers.unrealengine.com/questions/197994/grab-component-crash.html), the code you’ve provided is not enough to reproduce the issue. Could you please add the steps to reproduce the crash to the AnswerHub post as well as post a sample project where the crash is occurring to dropbox. You can then post the link or send me a private message here on the forum with the link to the project. It will be easier to provide help on the answerhub so I encourage you to post the information there.