I have a custom character class with an attached camera component, and a specified relative position of said the camera component. When I open the blue print of the character class I can see the camera component, but it doesn’t seem to honor the relative position I define in code. I can manipulate it in the blueprint itself, but not in the code anymore. For example, if I put the Z position at 200 in the C++ class, it still shows at whatever position (100 in my case) in the blueprint (and during execution). I assume this is the expected behavior, but it just feels like magic to me. How can I restore some of the control back to the code?
Blueprints are effectively child classes of whatever you attach them to.
So, if you define a Camera and change it’s behavior in the base class, but then create a blueprint and modify the behavior there - the blueprint will stomp your base class behavior. There are some ways around this (if you move your camera adjustments to OnPostLoad, you can enforce the previous behavior since that’ll be called after the Blueprint has been full initialized/loaded), but a good rule of thumb I personally use is simply not to expose fields in Blueprints if I don’t want them modified (or you can mark them as read only if you want them exposed, but want them safe from outside changes).
Thanks Matt, that helps quite a bit. I like your suggestion about keeping values read only, but how would you handle values that were inherited from parent classes? For example, on a projectile, I didn’t define an InitialLifeSpan initially. During testing, I realized I wanted to modify that, but at this point it looks like it’s already being trampled by blueprints. So at this point I can think of only two options:
- Use the OnPostLoad method you mentioned
- Recreate the blueprint with the newly initialized InitialLifeSpan value?
You could feed them a blueprint variable you setup that is inherited, or some other simple wrapper solution.
Thanks for the information , Click Here to get more notes on C++
Listening to Affirmation mp3 Audios makes a Person Life Peaceful