Moving actor from mouse location

Hey,

I’m trying to move an actor from where I clicked on the actor.
Atm, I have a DeprojectMousePositionToWorld then a linetrace, and I SetActorLocation to Hit.ImpactPoint.
But the problem is that the object is moving on the pivot point, and I’d like the location clicked with the mouse to be the temporary pivot point.

FVector MouseWorldLocation;
FVector MouseWorldDirection;
PlayerController->DeprojectMousePositionToWorld(MouseWorldLocation, MouseWorldDirection);
FVector TraceStart = MouseWorldLocation;
FVector TraceEnd = MouseWorldLocation + (MouseWorldDirection * 10000.f);
FCollisionQueryParams QueryParams;
QueryParams.AddIgnoredActor(this);
FHitResult HitResult;
bool Hit = GetWorld()->LineTraceSingleByChannel(HitResult, TraceStart, TraceEnd, ECC_Visibility, QueryParams);

if (Hit)
{
SetActorLocation(HitResult.ImpactPoint);
}

If you have any idea :slight_smile: