What should I be coding in C++ and what should I be using blueprints for?

So, I’m coming to Unreal Engine from Unity and I’ve seen in the tutorials that C++ shouldn’t be used to do everything, only as a base for the blueprint classes.
But what does this mean? What is a base? What should the C++ code do and what should the Blueprint be doing?

For example, lets say the player triggers an event by opening a door in a horror game, and the event triggers a guy to attack the player while hes opening the door.
Which parts of this would be coded in C++ and which would be made using Blueprints?

Or, a cube in a 2D-Sidescroller that the player can move, and climb to reach places high up, how should this be created?

In Unity I would just create a C# script called TriggerEvent.cs which basically tells the Editor what a event is, the C# script would probably have a variable called trigger or something, which can be set in the Editor and the C# script would trigger that variable, which is set to something in the Editor, such as a jump scare or a animation.

But since Unreal Engine also has blueprints, I’m confused on what I should use for which parts.

There is no real golden rule what you should do in which language. Theoretically you could do everything in C++, and theoretically you could do (almost) everything in Blueprint. The best practice however is somewhere in the middle.

The common wisdom is to write as much of your game logic as possible in C++ and then use Blueprint to wire everything together. In your example, the logic for moving the door, rotating it around an axis and applying that to the door actor’s transform, that would be C++. C++ can also expose a number of events, such as when the door is touched or when the player pushes a button to pull the door handle. You would then use Blueprint to wire one of those events to a trigger function on the enemy actor that wakes it up. The code for waking up the enemy and its related AI routines would again be C++.

The idea here is that all of your generic game logic (how does a door work, how can a player open a door, how should an enemy navigate a level, how should it attack the player) is written in C++, while Blueprint is used to configure specific instances of that game logic (opening this specific door will wake up this specific enemy), such that a level designer can easily place those actors in the level and wire them up accordingly.

Of course, with Blueprint being a fully fledged programming language, you can use it for a lot more than just basic wiring up of actors. Blueprint is also used a lot to quickly prototype new ideas, which are then later translated to C++ once the concept has solidified. You need to use your own instinct and common sense to judge which parts work better in Blueprint, and which parts are better left in C++.

Comparing to Unity, C++ takes the place of C# obviously, while Blueprint can be seen as a fancy alternative to Unity’s prefabs. Like prefabs, Blueprints are used to configure specific instances of your game objects (actors) and store them for easy application in a level. But unlike prefabs, Blueprints can also contain program logic of their own, which allows for much more flexibility in configuring and customizing your actors than just modifying a few variables.

I am part of an indie dev team comprised mostly of visual artists. We’ve been developing mostly relying on blueprints and then turning to C++ whenever we encounter limitations. Personally, I’ve found the blueprints system to be robust enough that I rarely have to move away from it. The example you describe can easily be accomplished entirely through blueprints (with perhaps some help from a behavior tree if the behavior you want is complex enough). Ultimately, it works. Of course, we work the way we do because it favors the node-based visual approach we are familiar with and we find it cuts down on debugging time (I am a notoriously error-prone typist), but if your background means you favor good old fashioned manual coding, then that might just be the way to go for you.

I would nonetheless recommend at least getting familiar with what different blueprints can already do out of the box. You wouldn’t want to find yourself reinventing the wheel.

If you are just starting to learn UE, it may be easiest to start with BP for everything.

Then begin digging in to c++ when the need arises.