UMeshComponent specification to Skeletal/Static in children
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)
Then in a child BP editor, i set the default value to static/skeletal mesh and compile (BP compilation, not C++):
but the compilation resets the default value (type) to None again.
if i set it in C++ constructor like this it does work (but i need it in BP)
answered Feb 17 '18 at 09:22 PM
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.
answered Feb 18 '18 at 11:47 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here