Download

creating classes - C++ or Blueprints?

Hey there!

Currently I’m planning to make something like an RPG and I’m thinking about classes like, let’s say, a NPC-class containing id, name, attributes etc.
Should I use Blueprints, based on the character class for that, or should I write my own class in C++ (which is new to me, as I used Java before and some scripting language called ‘Daedalus’ to mod an old RPG).
And if would write these classes in C++, can I still use these classes and functions and stuff in Blueprints to set game logic etc?

Looking forward to hear from you!

EDIT: not sure whether to post it here or in C++ section or even somewhere else

you can use c++ functions in blueprint. do what ever suits you best there is no wrong or right. if you want use both, then the parent should be c++ and the child bp

I found it easiest to have almost every class with a base in C++ and then Blueprints extending it so that the C++ Classes can easily manipulate the other classes. But, I prototype mainly in the Blueprint, once it’s set after experimenting I move all functionality that is off the Tick event into C++ but leave most of the stuff in Blueprint that is only called once in a while. I use Blueprints to set all the Game Data through exposed Properties and TArrays, so there is no C++ that is calling out game data by specific strings, but I do have C++ often initialize and spawn based off Class Names that are picked and set in Blueprint default and class settings.

Okay, thanks!

So… where do I start now? I’m not familiar with C++ in general, I just know that it’s syntax is almost the same as in Java, which is actually pretty good as I used Java before.
Now I want to create a general class for NPCs, so I created a new C++ class, named it “C_NPC” and choosed Character as parent. Now there are two files related to it. C_NPC.h and C_NPC.cpp.
No I want to define some basic attributes, such as id, name, level, hitpoints etc. But where do I do this?

the .h file is the header file. there you have to initialize the variables and functions. inside of the cpp (c++) you do the actuall code stuff

as and example in the header you would make
UPROPERTY()
float Health

and in the cpp file you can give it a value
Health = 100;

inside of the cpp file is a constructer you should define your default stuff there

Nice, thanks a lot!