I’m calculating the center of an actor, but the FVector I get is in local coordinates. I need to get it in world coordinates so that I can move the center of the actor where I need it to go in the world. Code I use to get the center and my not working attempt at getting the center in world coordinates:
/// Get center of actor
const FVector BoundsPointMapping[8] =
{
FVector(1, 1, 1),
FVector(1, 1, -1),
FVector(1, -1, 1),
FVector(1, -1, -1),
FVector(-1, 1, 1),
FVector(-1, 1, -1),
FVector(-1, -1, 1),
FVector(-1, -1, -1)
};
const FBox EachActorBounds = HitResultComponent->GetOwner()->GetComponentsBoundingBox(true);
const FVector BoxCenter = EachActorBounds.GetCenter();
/// Get center in world coordinates (doesn't work)
FIntVector IntWorldOffset = HitResult.GetActor()->GetWorld()->OriginLocation;
FVector WorldOffset = FVector(IntWorldOffset.X, IntWorldOffset.Y, IntWorldOffset.Z);
FVector CenterInWorld = WorldOffset + BoxCenter; ///World offset
PhysicsHandle->GrabComponent(HitResultComponent, FName(), CenterInWorld, true);