The thought process behind C++ and blueprints
So I've been fiddling with UE4 for a couple weeks now and I'm a bit confused on how exactly I'm suppose to integrate both C++ and blueprint into my workflow. I know this article:
says that the blueprint system is a great way for both the programmer and the designer to work with variables and functions. However, I've noticed something. In my 2d fighting game I have a camera actor. Within this camera actor I want to gather all characters found within the level and assign them to variables so I can use them in functions. I created my character class variables within my C++ CameraActor class. In order to assign them values I gather references of the actual characters at runtime with a for loop within the BeginPlay() function and assign these references to my declared character (pointer) variables. However, when I declare these variables to be used within the blueprinted class they are technically not yet assigned to anything (Since the BeginPlay() function in the C++ class isn't called until the game runs) and so I can't perform any operations on them without getting an error from blueprint.
My question is how am I suppose to think about the 'marriage' between C++ and blueprints in UE4? Should I only be attempting to expose variables to blueprint for which I plan to assign in blueprints? Or Is the programmer and the designer just suppose to both use the variable as they see fit (possibly resulting in duplicate code and other things) and then just reconcile the differences periodically? Any suggestions appreciated.
Im not big one in ue4 c++ so i dont quite understand problem described in first paragraph, but i have worked on c++ and blueprint project, with bp -> c++ and even c++ -> bp communication without any issues.
From my experience, i think Variables should be created and initialized in C++ as much as you can. Also avoid using dependent function on begin play, other objects might not be ready yet.
answered Apr 21 '16 at 05:21 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here