Convert a C++ pointer to a TSharedPtr

I am creating a pointer

PxRigidDynamic* KinActor = Scene->getPhysics().createRigidDynamic(KinPose);

and want to later store the object as a TSharedPtr:

TSharedPtr<physx::PxRigidDynamic> KinActorData;
KinActorData = MakeShareable(new physx::PxRigidDynamic*(KinActor));

But I get a compiler error:

error C2440: 'initializing': cannot convert from 'physx::PxRigidDynamic **const ' to 'physx::PxRigidDynamic *'
note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
note: see reference to function template instantiation 'TSharedPtr<physx::PxRigidDynamic,0>::TSharedPtr<physx::PxRigidDynamic*>(const SharedPointerInternals::FRawPtrProxy<physx::PxRigidDynamic *> &)' being compiled
note: see reference to function template instantiation 'TSharedPtr<physx::PxRigidDynamic,0> &TSharedPtr<physx::PxRigidDynamic,0>::operator =<physx::PxRigidDynamic*>(const SharedPointerInternals::FRawP
trProxy<physx::PxRigidDynamic *> &)' being compiled
error C2439: 'TSharedPtr<physx::PxRigidDynamic,0>::Object': member could not be initialized
note: see declaration of 'TSharedPtr<physx::PxRigidDynamic,0>::Object'

What is the correct way to assign a C++ pointer to a TSharedPtr?

new physx::PxRigidDynamic*(KinActor) returns a pointer of type physx::PxRigidDynamic** const.

just use

 KinActorData = MakeShareable(KinActor);

Thanks for the help, but “KinActorData = MakeShareable(KinActor);” just gets me a different error:

\runtime\core\public\templates\SharedPointerInternals.h(115): error C2248: 'physx::PxRigidDynamic::~PxRigidDynamic': cannot access protected member declared in class 'physx::PxRigidDynamic'
\thirdparty\physx\physx-3.3\include\PxRigidDynamic.h(396): note: compiler has generated 'physx::PxRigidDynamic::~PxRigidDynamic' here
\ThirdParty\PhysX\APEX-1.3\module\destructible\public\NxDestructibleActor.h(26): note: see declaration of 'physx::PxRigidDynamic'
\runtime\core\public\templates\SharedPointerInternals.h(114): note: while compiling class template member function 'void SharedPointerInternals::DefaultDeleter<ObjectType>::operator ()(Type *) const'

Destructor of that type is protected and can not be accessed from TSharedPtr code as it seem it needed it, so this type is effectively not supported by TSharedPtr. You will need to use raw pointer and manage it manually

Ok, thank you for your answer.