How to get Actor's primitive to disable Physic emulation?

I’m trying temporary disable physic emulation on random target object. It can be sphere, box, capsule, anything… by class UPrimitiveComponent. So, I’m using SetEmulatePhysics BP. And it need UPrimitiveComponent input.
So, i made custom blueprint function with code:

UPrimitiveComponent* UMyEdGraphNode::GetActorPrimitive(AActor* actor){
	//UPrimitiveComponent * comp;
	return (UPrimitiveComponent*)actor->GetComponentByClass(TSubclassOf <UPrimitiveComponent>());
}

It is an error, because GetComponentByClass function returns UActorComponent type. How can I convert it? Or may be another way to disable physics temporary without loosing it’s physics state?

#Get Root Component

You should be able to just use Get Root Component of the Actor who has the component that could be of any particular primitive type

GetRootComponent()

Rama

I need Primitive type of return value

GetRootComponent returns Scene Component

You can easily cast USceneComponent to any other component you want.

UPrimitiveComponent* Primitive = Cast<UPrimitiveComponent>(GetComponentByClass..);