Changing components in c++ doesn't remove old ones from blueprint

Had an interesting problem the other day when I built a blueprint from a c++ Character class that had a CameraComponent created in the constructor. We then decided to try an implement a camera from the Controller class, so removed the component form the controller, but then I changed my mind and added another camera back into the character class this time on a boom. When testing it it kept going first person instead of looking down from the boom.

It wasn’t until I de-referenced the blueprint in code, deleted the blueprint in editor, built new blueprint from same class then reset it to the DefaultPawnClass that it used the boom.

1 Like

Hi Aidan -

When you remove a native component like that, you need to add a redirector to your Engine.ini file to make sure that it doesn’t get serialized in again. Here’s an example:

+ActiveClassRedirects=(OldClassName="MyComponentClass",OldSubobjName="MyComponentName,NewSubobjName="")

That will cause the subobject to be removed if there’s one stuck over from serialization, and that should prevent the problem above! Hope that helps!

when you make changes to components in code or in the editor

make sure to re-compile your blueprint

specifically by clicking that recompile button next to the save button

then the native code and the editor blueprint and all components should update correctly

:slight_smile:

Rama

Did that multiple times (actually deleting the blueprint was a last ditch effort after about 20 min of head scratching) might be a bug then? Do you want me to see if I can replicate it?

if you can reproduce the same asset with the same problem, and then put it on drop box Epic staff can help you from there :slight_smile:

Rama