Download

Physics Handle movement?

Hi! I’m trying to setup the ability for my player to grab physics objects in my game and move them around.
I currently do a trace to get the location and object I want to grab and have setup a physics handle. But the second parameter GrabComponentAtLocation expects the name of a bone? What bone and for what purpose? The item I’m grabbing doesn’t have any bones.

Edit: So I got it working, but the handle isn’t attached and stays and the triggered location and has no attachment function. So I can hold the object in place, but not move it. How do I get and attach it to a bone or component of my choice?


void ATribesmenCharacter::Interact()
{
    bHeld = !bHeld;
    if (bHeld)
    {
        FHitResult TraceHit;
        FVector Start = PlayerCameraComponent->GetComponentLocation();
        FVector ForwardVector = PlayerCameraComponent->GetForwardVector();
        FVector End = ((ForwardVector * 1000.f) + Start);
        FCollisionQueryParams CollParams;


        if (GetWorld()->LineTraceSingleByChannel(TraceHit, Start, End, ECC_Visibility, CollParams))
        {
            if (TraceHit.bBlockingHit)
            {
                DrawDebugLine(GetWorld(), Start, TraceHit.ImpactPoint, FColor::Red, false, 4, 0, 1);
                DrawDebugSphere(GetWorld(), TraceHit.ImpactPoint, 30, 12, FColor::Yellow, false, 4);
                PhysicsHandle->GrabComponentAtLocation(TraceHit.GetComponent(), "none", TraceHit.ImpactPoint);
                if (GEngine)
                {
                    GEngine->AddOnScreenDebugMessage(-1, 1.f, FColor::Red, FString::Printf(TEXT("Impact Point: %s"), *TraceHit.ImpactPoint.ToString()));
                }
            }
        }
    }
    else
    {
        PhysicsHandle->ReleaseComponent();
    }
}

Edit: I could set the location each tick I suppose, but that’s not the best way of handling it, is it?