Talk about generic C++ classes

Hello, I did my first UE4 game for the latest LudumDare, you can test it here
http://gamejolt.com/games/golden-rush/113672

link video

I would like to talk about the C++ that could be implemented here.

I want to expand the game and add behaviours, animals.
For example, I want to add a snake that grows with shapes.
I wonder what it is the best way to do generic classes for all the puzzles. What would be better…a player controller class for each type of animal or a generic class, what would i win if i choose to do a c++ based blueprint instead of a pure blueprint? I mean, what’s the point of a C++ class if you can do almost everything in BP.
I’m a programmer for more than 2 decades now and I love to code, but after I completed the battery C++ tutorial
link c++ done

I don’t understand why should I have to create C++ classes if I can do directly blueprints.

For this game, from the ludum dare, in my mind, I have this:

  • A tutorial level with each animal to learn the basic game mechanics
  • After completing the tutorial, you fall to the world where you control the animal in an open-world minilevel where you can find the game mechanics from tutorials but with other combinations and stuff

Having this idea in mind, what would be the way to group classes:

  • A World BP/class to control everything in the Generic (Universal) scale and store stuff that is shared between behaviours
  • Puzzle BP/class to control all the puzzles?
  • Animal BP/class to control all the kind of animals/players

This is so hard to say ,but i think i’m not doing it right, and i’m talking about design here.

i recommend using a single player controller for your whole game, and making a separate pawn for each animal type. i don’t recommend trying to make some kind of generic puzzle manager, because you could just keep track of that progress inside the player controller. for puzzles, you can have each interactive object be its own blueprint, with its own logic. you can treat player progress the same as collecting items, where an environment object tells the player’s pawn to tell its player controller to run some interface function that adjusts their score/flags/inventory data.

you don’t need to use C++, but if you do, you can make custom movement components for pawns, adjust the global audio volume, write data to text files, work with Tsets and TMaps, and its a bit easier to edit nested arrays/structs. in C++ you can access the viewport client and have more control over split screen options, you can set the mouse cursor position, you can customize details panels to add special menu layouts for some data (like the color picker, or drop down lists), you can make templated functions, you can work with quanternions, you can use Enums as bit flags for compressing booleans into an integer (you could kinda do this in blueprint, but its a little more hacky), you can get the default properties of a variable at runtime, you can have pointers that point to other pointers, and probably a bunch of other stuff.

Importent thing to know about C++ when you come from BP, is that API whise is exact the same, same events same functions and most impotently same classes, about 90% of all nodes in BP are bindings from C++ functions of engine code, there also special functions in engine for BP to fill missing features of C++ syntax in BP. Blueprint themselves are same valid classes as C++ classes, you can see that in Class Viewer ( hiding it deep in “Window” menu Epic messed with people heads, in UE3 and older this was main actors list). So if you know BP, you will know naturally what to do in C++, you just need to… feel it :stuck_out_tongue: I demonstrated that in my video about objects and classes:

Whatever class you make in C++ and which in BP it's your design decision, in both you can do the same but more in C++

Pros of C++ is definitly performence, aspecially in Tick where you got only 16ms to fit in 60FPS, also there ton of functions which are not accessible thru BP (but that number constantly increasing), you have full interaction with engine… as well as editor which BP complily lacks (except Blutility), for example you can alter actor behavior in editor, way of editing it

Pros of BP is a lot easier access to assets (in C++ you either need to statically link asset, or make varable which you will set in BP… thats how good BP is with interaction with assets), fast compile time, so easier to play with things.

Personally i go with this philosophy do base classes and varius systems (the kernel of the game) in C++ and set up specific actors in blueprints, this makes programmer<->artist interaction a lot easier

Thanks Omnicypher.
Ok, I think it’s easier to do things with Blueprints and compilation time is faster. But I noticed that physics objects like boxes in the c++ third person ship default project for “Twin Stick Shooter” starts with a little bit “lag”, compared with the same default project in its blueprint version.

Thanks for this info, I think it’s important and good to know.
I like the compiling time with BPs really, and I love the idea of a C++ core for the game. Good words