A couple of C++ questions...

Hi,

I am only a few hours into UE4.7 and currently following 3d person game tutorial with C++ and blueprints. But I do have a couple of questions, mostly of Yes/No nature…

  1. I see that they use these blueprints to extend C++ classes. Do I need to use blueprints for game logic ? Seems more complicated then a few lines of code I could add quickly in the Tick event. Can a game in UE4.7 be written without using blueprints and just using C++.
  2. Are these C++ solutions normal C++ soltuions ? What I mean by that is - I have my own 3D engine that I spent over a year writing from scratch. Having heard that UE4.7 is now free with 5% income distribution, and considering that I still have to write in audio, special effects, and level editor into mine, I thought I’d check this instead. However, I do have some pieces there that I’d like to carry over - primarily questing system that’s based on Lua and my own XML based character dialog system. Can I just add those with the main unreal solution and use them from there ?

Thanks

Yes

Yes, though you will probably want to expose some properties to BP to be edited quickly either while the game is running or once your code base gets quite large and compile times take a long time.

The only thing you really should expose to BP is asset references! Dont hard-code asset references as they have a tendency to break during packaging! Link all your assets using UPROPERTY variables defined in C++ base classes.

No game logic has to be done in BP at all and can only run slower.

Math runs about 10x slower in BP than in C++, all math and therefore all AI should be done in C++!

I offer a more thorough answer to the BP vs C++ question :

If you use a Github version of UE4 you have full C++ access to compile the Engine and edit it anyway you want.

I recommend you confine your C++ changes to the project-level as much as possible to make engine-upgrading easy and fun process.

You can add any C++ you want to your project, or the engine level if you have a github engine.

You have all the power of UE4 and C++ at your disposal, welcome to UE4 C++!

Sweet. Thanks for the quick response ! Oh, one more thing - in particular regarding those two features - Lua import and XML dialogs… That can be project level , rigth ? No need to mess around with the github version engine for this ?

You mean I should avoid doing something like this?


static const ConstructorHelpers::FClassFinder<ACharacter> playerCharacterBpClass(TEXT("Character'/Game/Characters/PlayerShip.PlayerShip_C'"));
if (playerCharacterBpClass.Class != nullptr)
{
	DefaultPawnClass = playerCharacterBpClass.Class;
}

Would you mind elaborating on how you would do this then?

Actualy it do not realy make sence to set the DefaultPawnClass in code.
You can set all thos propertys from the Editor. (Edit > Project Settings > Maps and Modes)
Just make the classes and add the Class or a derived Blueprint from the dropdown menu.

Out of curiosity… With the above being said, why does the UE4 documentation seem to be heavily slanted towards blueprints ? As I am going through the documentation I see that a lot of sections have subsections like “Input using BluePrints” or “Navmesh using Blueprints”, etc, but barely ever C++ examples. Those are just scattered among a few how-tos in “C++ programming guide”. Are there some good C++ docs out there ?

For example:

https://docs.unrealengine.com/latest/INT/Gameplay/HowTo/FindingActors/Blueprints/index.html

Why no “How to find actors of class using C++ objects?” . How would one find equivalents of those by looking at the documentation.

in my case , I started with blueprint until i felt comfortable with , then i switched to c++ by converting my projects to c++.
this helped me alot in this process



Sweet. Didn’t notice that there was “go to code definition” for those native functions/events in the blueprint. That helps alot ! For some reason for me it doesnt take me directly to the function in the code, but it does get me to the header so I can usually find it there by typing a few keywords from the blueprint function name. Thanks !

I see. Thanks for the advice! I created a Class Blueprint that inherits from my Game Mode and set this stuff through the project settings like you mentioned now. :slight_smile: