I have a multi-wheeled vehicle I’m trying to code in c++. The idea is to have the meaty parts coded in c++ and use a BP wrapper to specify the static mesh components that make up the vehicle. Right now, I can specify the main chassis static mesh component just fine. The tricky part is the chassis can a variable number of wheels. What needs to happen is for the BP to accept a drag/drop from the content browser which allows the wheel’s static mesh to be selected and passed to the c++ parent of the BP. The c++ code will then add the wheels as subcomponents to the chassis as needed when the actor is spawned. I have this declaration in the header file:
Unfortunately, TSubobjectPtr seems to be deprecated –
EMIT_DEPRECATED_WARNING_MESSAGE(“TSubobjectPtr is deprecated and should no longer be used. Please use pointers instead.”)
I went back to using pointers and it compiles and runs. But it’s not right …
// doesn’t work
UPROPERTY(VisibleDefaultsOnly, Category = MyVehicle)
UStaticMesh* RoadWheel;
// this works, but not what I want
UPROPERTY(VisibleDefaultsOnly, Category = MyVehicle)
UStaticMeshComponent* RoadWheel;
I just need the name of the static mesh passed from the BP to the c++ rather than having the BP create an instance of a static mesh component. The code will create n-number of components from there on its own.
The above code can only set the mesh in the world detail panel (BP Character(Child) … ThisMesh), i didnt manage to find a proper UProperty settings that allows setting of mesh in the BP editor. You might have to dig around for that settings if you need that. Hope this is what you need for your project.