Grab() doesn't pickup component until "bumped"

When input action for grab has sweep hit on the statue, I see the debug sphere on the mesh at HitResult.ImpactPoint … so I know “HasHit” is true… BUT the object doesn’t move until I’ve bumped into it with the player mesh. After that, the statue moves around on a spring in front of player camera view.

Confirmed the mesh has simulate physics enabled and is set as movable. (It does move but only after bumping into it with player mesh).

I made sure it’s place well above the floor and away from walls so it isn’t “stuck” inside the other meshes.

Anything wrong with this logic?..

	if (HasHit)
	{
		UPhysicsHandleComponent* PhysicsHandle = GetOwner()->FindComponentByClass<UPhysicsHandleComponent>();
		if (PhysicsHandle == nullptr)
		{
			return;
		}

		AActor* HitActor = HitResult.GetActor();
		UE_LOG(LogTemp, Display, TEXT("DEBUG: Hit: %s"), *HitActor->GetActorNameOrLabel());
		DrawDebugSphere(GetWorld(), HitResult.ImpactPoint, 10, 10, FColor::Cyan, false,	5);

		PhysicsHandle->GrabComponentAtLocationWithRotation(
			HitResult.GetComponent(),
			NAME_None,
			HitResult.ImpactPoint,
			GetComponentRotation()
		);
	}
	else {
		UE_LOG(LogTemp, Display, TEXT("DEBUG: No actor hit."));
	}
1 Like

The answer to my question was in the very next lecture about “Waking Physics Objects”.

Oh well… was good mental exercise to think through the code. I knew there was something going on… makes a lot of sense now that have watched the Waking Physics Objects lecture.

4 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms