Thank you. Trying a wake rigid after release on the component variable lol. Been Weeks! on this one. May the Code Force always be with you.
*(update) I may have spoke too soon. It still snaps back to last known position, when released / rewoke / regrabbed. :-*
(update) I had 2 release nodes in my blue print, fired for different events. After removing one of the release nodes the old location does not seem to be sticking. No snapping back to last known location or last known released location.
Hello there,I did all the steps you are suggesting, also waking the rigid body and adding a small impulse, but still it does not work sometimes. I also tried to check if the physic handler returns a null pointer if the actor did not get grabbed, but it returns that the actor is grabbed even if it´s not…Hope you can helpp!!!
if(HitResult.GetActor()->ActorHasTag(TEXT(“Collectable”)) && PhysicsHandle)
{
//If inventory open do nothing
if (bDoLineTrace && !bIsInventoryOpen)
{
UPrimitiveComponent\* Prim= Cast<UPrimitiveComponent>(HitResult.GetComponent());
if (!Prim->IsSimulatingPhysics())
{
Prim->SetSimulatePhysics(true);
}
Prim->WakeAllRigidBodies();
Prim->AddImpulse(FVector(0.f, 0.f, 1000.f));
const FVector GrabLoc = Prim->GetCenterOfMass();
TargetActor = HitResult.GetActor();
if(!TargetActor) return;
UE_LOG(LogTemp, Warning, TEXT("Collect object"));
PhysicsHandle->GrabComponentAtLocationWithRotation(Prim,NAME_None,GrabLoc,TargetActor->GetActorRotation());
GrabComponent->OnGrab(PhysicsHandle,TargetActor);
if (PhysicsHandle->GetGrabbedComponent()==nullptr) {UE_LOG(LogTemp, Error, TEXT("It did not grab the objectttttt")); return;}
bDoLineTrace = false;
//bObjectGrabbed = true;
SoundHandler->PlayPickUp();
// SAVE THE NEW ITEM AND PLAY MEDIA IF IT´S AUDIO OR VIDEO
if (AInventoryItem\* Item = Cast<AInventoryItem>(TargetActor))
{
if (PhysicsHandle->GetGrabbedComponent()==nullptr) {UE_LOG(LogTemp, Error, TEXT("It did not grab the objectttttt")); return;}
if (!OMC) return;
OMC->SaveNewItem(Item);
PlayItemMedia(Item);
}
}