so I’am working with UE4 for couple of months and started to know it and like it. But still there is this one question I dont have answer for: What kind of logic should I put into blueprint scripting and what into C++? Are there any general or best practices about it? Is it OK to use blueprint types in C++ and vice versa? Whats the intended way of communication beetwen blueprints and C++? Over and over again I run into situation when I want to use types defined in blueprints from C++ code.
For example: I created BP_Rocket blueprint which is an Actor and represents rocket. Now in C++ I want to write function that spawns BP_Rocket and configures it in some way. Is doable ? Is it the way it should be done? Or maybe I should refactor logic from BP_Rocket to C++ and make everything work on the C++ side?
Here are some rules of thumb I use when developing code that will be shared among teams of artists and programmers:
Does it need to iterate arrays or loop? Implement it in C++ and expose it as a single node in Blueprint.
Does it need to pass by reference or allocate on the heap? Implement it in C++ and expose the most simple nodes possible to Blueprint.
Does it require ordering of stateful changes, special logic for Begin/End play, or network replication that can be broken through improper mutation? Don’t expose it to Blueprint at all. Implement it as a component that can be added to an actor by Blueprint, or as an Actor subclass.
Generate events for things that happen in your game world that are implemented in C++ whenever possible. Things dying, getting hit, spawning in, etc. These are great candidates for artists to hook into and trigger sound effects, particles, etc.