In my case i try to make a generic UMeshComponent in C++ to further specify whether it will be a Skeletal or a Static mesh in the child classes. (i need half of the children skeletal and half static)
This is a longstanding blueprint limitation that there is no ideal solution for. An epic staff mentioned wanting to allow this back when I first started using UE4 3 years ago. I wouldn’t hold your breath.
There are various workarounds. The simplest approach is to make your variable VisibleAnywhere, and simply require the component to be added to the child blueprint in the regular way via the AddComponent button. Then in C++ BeginPlay or similar, you find the component using FindComponentByClass (or similar variant) and cache it in your variable for future access. Main drawback to this method is that you can’t cleanly enforce that child blueprints always have the component of an acceptable type added.
It’s possible to go the route you tried with a dropdown instanced property, but it involves kind of going against how the engine deals with components. You need to start overriding PostEditChange to register/unregister the component etc, and there are also potential issues related to construction script like you’ve seen. I’ve found it’s not worth the bother.
thanks for the detailed info, however it is not an instanced property. the dropdown way i try is actually in the child BP defaults (class-wide)
basically overriding
Pretty sure we’re talking about the same thing. All components are marked ‘InstancedByDefault’ and ‘EditInlineNew’, so by making a component property EditAnywhere, you have an instanced property. The issue is that components require special registration, which doesn’t happen automatically when you create it via an instanced dropdown.