I have the same problem.
I had to change my UBoxComponent to USphereComponent in my already component packed BP.
I donât want to re-create the BP from scratch, I spent quite a bit of time on it.
Any ideas?
Or perhaps creating components in C++ and editing them in BP is not the way to go. Perhaps itâs better to create the components in the BP editor and bind them to the C++ variables using the Construction Graph.
The only thing that bothers me with creating components in the BP instead of code is that Iâm not sure on the corrupt rate of blueprints. Iâd have to redo even more stuff if that blueprint were to get corrupted my something else somehow
Very good argument. I think we need to wait for Epicâs answer. I am on holiday now, but I will submit a bug report when I go back home.
In the meantime, is there any way to fix that corrupt blueprint?
There are definitely some issues with the robustness of the interaction between C++, Blueprint and CDOs. It can lead to some really awkward to solve problems. Iâm not certain this is the issue you have, but the following may help.
Iâm assuming you were initializing the component in C++ in the constructor. When you change the component type, the next time you load your BP it will fail to load the property, and probably sets it to null.
If you now put EditAnywhere in your component property specifiers rather than VisibleAnywhere, then build and run, in your Blueprint you should then see the yellow âreset to defaultâ arrow next to your component in the details panel. Hopefully if you click that, it will reinitialize the blueprintâs component back to whatever you assigned to the new component in your class constructor. If so, you can then just save the BP and then switch back to VisibleAnywhere again.
That didnât work, sadly. I couldnât see any arrow because the details panel is not rendering anything. For what itâs worth, here is how I declare my properties in the header and how I initialise them in my constructor:
(the CollisionBody has its type changed, this is the corrupted one)
This could also be a good chance to ask where to add collision callbacks. Would it be best to do in the BeginPlay, or the constructor? More specifically, what should be initialised in the constructor and what in the BeginPlay? It feels like only components should be initialised in the constructor, am I correct?
Hmm, I just did a quick test by making a component EditAnywhere (note that generally your components should be VisibleAnywhere, but maybe they were before my suggestion) and setting it to None in the blueprint editor. On reselecting the component the details panel was blank, as you say. I wonder if this is a bug introduced in a recent version - the way components and their properties are displayed in the blueprint editor has changed from when I solved my similar issue a while back. Not sure what else to suggest.
As for callbacks. This is not something Iâve had confirmed by anyone, but I now avoid registering delegates in constructors. I had an almighty bug hunt a while ago where I couldnât work out why my overlap handler wasnât getting called. It turned out that a delegate Iâd registered in my constructor had somehow been stored (presumably within the blueprint CDO) and remained there even after I changed the code to use a different delegate - despite the fact the original method had been removed from the class entirely, it was still stored in the delegate by name. When I deleted and recreated the blueprint the issue went away.
The idea that blueprints can get into invalid states as a result of just making changes to their parent class really doesnât sit well with me. Anyway, I concluded that registering the delegates in the constructor was the cause in that instance, but I canât be sure.
I think that I will have to rebuild the blueprint from start, I donât see another way
This is really frustrating and feels very dodgy⌠especially in the case of prototyping/iterating where components and their types change almost daily. This can lead to enormous problems. The option of setting the components in the blueprint and linking them to tjhe C++ variables is not ideal either since my AShip class will be used to make dozens of blueprints, Iâd like their components to be at least initialised in the order I set in C++.
Callbacks and anything that needs to be initialised when the game runs, I think Iâll just put them in BeginPlay. I am consulting the UT sourcecode for some things and following in their footsteps (although I am not sure about the callbacks and how they handle the aforementioned blueprint problem).
Okay, this is not a solution or an answer, however it seems that the detail panel is broken only in the full blueprint editor. If you drag your class blueprint in the scene view and inspect its components they are fine (including the previously broken one!).
After reading through this post I noticed that the bug being reported (the details window being blank after changing a code component) has been fixed and tested on our internal 4.8 build. Please let me know if youâre still seeing this issue once 4.8 is released.
, Iâve just upgraded to 4.8 and gave this a quick test, unfortunately the issue appears to exist just as it was before. Here are precise repro steps (probably including a number of things that arenât strictly necessary):
Create new blank project.
Add new C++ class, derived from Actor.
Add new blueprint, based on new C++ class.
Close editor.
Add in the header:
UPROPERTY(VisibleAnywhere, Category = âComponentsâ)
class USphereComponent* PostBP_OriginallySphereComponent;
Open blueprint, all should be fine, save blueprint, close editor.
Replace âUSphereComponentâ with âUBoxComponentâ in the header and cpp, but leaving the member variable name and the literal name unchanged.
Compile and run project.
Open blueprint. Select the component in the components list, in details panel it will show as âNoneâ.
Note that instances of the blueprint subsequently added in the level editor work fine. Further, the box component will display in the blueprint editor viewport even though it is shown as âNoneâ in the details panel.
Also, if having reached step 11, you comment out the line in the header and in the cpp, then repeat 7 & 8, uncomment and compile/run again, the problem will go away. So it seems (at a guess) that the serialization of the blueprint/CDO can cope with a change to a component type if done in two steps (removal first, then reintroducing with a new type), but if itâs done in one step then it fails.
Edit: Sorry canât fight anymore with the autonumbering!
I was able to reproduce what youâre seeing using the code and steps you provided and have reported the bug (UE-18284) for investigation. I did find that this only occurs when using the âVisibleAnywhereâ specifier inside the UPROPERTY() macro. Using EditAnywhere instead will set the component or provide the yellow reset arrow if not set automatically.
The Bug report mentioned (UE-18284) is still open for investigation by developers. Can you provide any information about your setup or the results youâre seeing? As mentioned, if youâre using VisibleAnywhere in the UPROPERTY() of your variable then this will occur and can be avoided by using EditAnywhere instead.
I have a custom character subclass with its own movement component. I am using the âSetDefaultSubobjectClassâ method in the constructor to assign my movement component class to the pawn in lieu of the default one. As you can see, I am doing the same with the Capsule component. The capsule component assignment works correctly, but the movement component, does not. The code compiles, but when I open any blueprint deriveded from my custom character, the movement component appears as âNoneâ.
Unfortunately the workaround of using the âEditAnywhereâ specifier doesnât help me , because the CharacterMovement UProperty is defined in Character, which is an engine class and Iâd prefer not to change engine headers if it all possible.
Iâm trying to recreate the setup from your screenshot and want to make sure Iâm doing the same thing you are. Are UME_CharacterCollisionComponent and UME_CharacterMovementComponent classes youâve created? Also, are you able to use SetDefaultSubobjectClass inside the constructor rather than adding the code to the Super?