# Why physics handle is not rotating grabbed object?

**URL:** <https://forums.unrealengine.com/t/why-physics-handle-is-not-rotating-grabbed-object/485406>\
**Category:** World Creation\
**Tags:** physics-handle, rotation, unreal-engine, Physics, question\
**Created:** [June 26, 2021, 3:43pm UTC](https://forums.unrealengine.com/t/why-physics-handle-is-not-rotating-grabbed-object/485406 "2021-06-26T15:43:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiagorvmartins](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tiagorvmartins](https://forums.unrealengine.com/u/tiagorvmartins)\
**Post date:** [June 26, 2021, 3:43pm UTC](https://forums.unrealengine.com/t/why-physics-handle-is-not-rotating-grabbed-object/485406/1 "2021-06-26T15:43:19Z")

</div>

Hello!  
I have a physics handle component that is grabbing another static mesh, the setTargetLocation is working properly the object changes location, however I was expecting that the object would rotate around his center of mass by default when floating in air, right?

That’s not happening, I have done setSimulatePhysics true on the grabbed mesh as well.

**Here is my physics handle current settings:**

![342505-settings.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/4/1/841a9234e436b4c80db8b2ea550c6146d69e28e7.png)

**And here is my code:**

**The c++ class that contains the mesh to be grabbed:**

```
AGameCube::AGameCube()
{
 	// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

	UStaticMesh* cubeMesh = nullptr;
	static ConstructorHelpers::FObjectFinder<UStaticMesh> CubeMeshAsset(TEXT("/Game/Meshes/GameCube"));
	if (CubeMeshAsset.Succeeded()) {
		cubeMesh = CubeMeshAsset.Object;
	}

	CubeMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("GameCube"), false);
	if(CubeMesh && cubeMesh) {
		CubeMesh->SetStaticMesh(cubeMesh);
	}

	CubeMesh->SetSimulatePhysics(true);	
	CubeMesh->SetCollisionObjectType(ECollisionChannel::ECC_PhysicsBody);
	CubeMesh->SetCollisionResponseToChannel(ECollisionChannel::ECC_PhysicsBody, ECollisionResponse::ECR_Overlap);
	CubeMesh->SetWorldScale3D(FVector(1.f,1.f,1.f));
	CubeMesh->SetMassOverrideInKg(NAME_None, 50.f);	

	SetRootComponent(CubeMesh);

}

```

**Here I am grabbing the object:**

```
void UGrabber::Grab()
{	
	FHitResult Hit = GetFirstPhysicsBodyInReach();	
	UPrimitiveComponent* ComponentToGrab = Hit.GetComponent();	
	AActor* ActorHit = Hit.GetActor();

	if (ActorHit)
	{
		if(!PhysicsHandle)
		{
			UE_LOG(LogTemp, Error, TEXT("Gonna return no Physics Handle"));
			return;
		}		

		AGameCube* GameCube = Cast<AGameCube>(Hit.GetActor());	
		
		
		FVector Location;
		FRotator Rotation;
		GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(OUT Location, OUT Rotation);

		FVector newLoc = (Location + Rotation.Vector() * Reach);
		FVector compLoc = ComponentToGrab->GetComponentLocation();

	

		float distance = FVector::Dist(newLoc, compLoc);
		Reach = Reach - distance;
		PhysicsHandle->GrabComponentAtLocation(ComponentToGrab, NAME_None, compLoc);
	}
	
}

```

**And here is the tick function to update the location of the grabbed object:**

```
void UGrabber::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
	Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

	if(!PhysicsHandle)
	{
		return;
	}

	

	if (PhysicsHandle->GrabbedComponent)
	{
		FVector Location;
		FRotator Rotation;
		GetWorld()->GetFirstPlayerController()->GetPlayerViewPoint(OUT Location, OUT Rotation);
		

		//Ray-cast out to a certain distance (reach)	
		FVector newDestination = (Location + Rotation.Vector() * Reach);
		

		PhysicsHandle->SetTargetLocation(newDestination);

		
	}

	
}
```

---

<div class="post-metadata">

**Author:** ![Vlady\_Veselinov](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vlady_veselinov/32/621446_2.png) [@Vlady\_Veselinov](https://forums.unrealengine.com/u/Vlady_Veselinov)\
**Post date:** [June 3, 2022, 3:48am UTC](https://forums.unrealengine.com/t/why-physics-handle-is-not-rotating-grabbed-object/485406/2 "2022-06-03T03:48:37Z")

</div>

You need to use `GrabComponentAtLocationWithRotation`
