A couple of doubts, a couple of questions :D

Hi guys, i am a programmer, i do C, C++, Java EE, Javascript, HTML, .Net and some more. i am an computer engineer student. i DONT LIKE blueprints, so here i am learning UE4 C++ API.
Questions:

1- About C++ workflow,is this correct? -> i create a new C++ project, i create my C++ componenet (Called robot)and inside this i build the staticMesh and bla bla bla. Then i create a GameMode class and inside it i create and spawn my robot. i manage, in the gameMode, where and how my robot will spawn and so on. is this correct? i heard about LevelBlueprints but in the API it is called ULevel(described as ‘a collection of all Actors’) and mostly i didnt saw any tutorial using it in C++ code. i know the UGameInstance is used to code global and persistent behavior but i didnt used it yet.

2-About loading and configuring 3D assets, i have my robot, and my 3D model of that robot. i create my C++ with the robot´s behavior and then i have to load at runtime the 3D asset using C++( and modify location, rotation in world space and local space). i know i can build the 3D assets using blueprints and then add behavior using blueprints, but since i dont want to use BP,
is there any way to build graphically the 3D asset(like in BP) and then add to it C++ code? it is like a bit tedious having to modify the location and position to every model in a test and error never ending process.

3- I found that i can create a new BP, load my 3D assets and configure them(position, rotation, scale, relative and world) graphically. And i found that i can add a C++ component to the hierarchy, but then i must have to work with the robot using BP, since i cannot extend a BP using C++, is this correct ?.

4- i create GameModes classes, and maybe C++ components like actors and characters. but i can´t delete those once created. **how should i delete them? **when i do right click over the GameMode for example, the ‘Delete’ text appears in grey, not clickeable.

PD: the robot example is just an example, to have an idea to give you scenarios. i am not working with robots xD

1- About C++ workflow
Not entirely correct. You should create an Actor. Actors are “containers” of components like Meshes, Lights, data etc. If you want to control that robot with input, then it should be a subclass APawn.
The GameMode has a variable called DefaultPawnClass, just set it to ARobot::StaticClass(); in the constructor and it will spawn the robot actor for you.

You don’t really need LevelScript unless you are really designing code that just lives in a specific map.

2-About loading and configuring 3D assets
The best way of doing it is just to implement all the components in C++ and then make a BlueprintSubclass of it. In the Blueprint you can edit the asset references easily.

3- C++ Actor Composition
Extending the first 2 points. Actors are made up of components. That is really what you do when you create a blueprint. You create an actor and in that actor you add components like meshes.

You can do the same in C++ like this



//////////////////////////
// Robot.h
/////////
.
.
.

/** Reference to a SkeletalMeshComponent */
UPROPERTY(VisibleDefaultsOnly, Category = Mesh)
class USkeletalMeshComponent* Mesh;

.
.
.



//////////////////////////
// Robot.cpp
/////////
.
.
.


//Constructor
ARobot::ARobot(const FObjectInitializer& ObjectInitializer)
	:Super(ObjectInitializer)
{

	Mesh = ObjectInitializer.CreateDefaultSubobject<USkeletalMeshComponent>(this, TEXT("Mesh0"));
	Mesh ->AttachTo(GetRootComponent());
}


The example above adds a SkeletalMesh component to your actor. You can now create a new Blueprint and Select Robot as ParentClass. That gives you access to the components on C++ and Blueprint level.

**4. **

No Idea what you mean here.

  1. For your Robot you need to create an Actor. Actors are the base class for game objects and they can have components like UStaticMeshComponent. You can manage your Level Blueprint from C++. Rama has a great tutorial on it: https://wiki.unrealengine.com/Solus_C%2B%2B_Tutorials#Solus_C.2B.2B_Tutorial:_Creating_Custom_Level_Blueprints_in_C.2B.2B
  2. I don’t really understand the question.
  3. Yes, you cannot extend Blueprint Class using C++, but you can extend C++ class using Blueprint so that it will derive from your C++ base class. I really recommend using this approach because Unreal Engine is most powerful when you combine both C++ and Blueprints.
  4. That’s probably because you can’t delete C++ classes from Editor. You need to remove them from code and the recompile the project.

To delete classes I go into Win Explorer and delete the actual files, then rebuild the solution files. Seems the cleanest way.

If you’re using Source Control though, you’ll have to make sure everybody checks out and rebuilds their own solution files too.

WoW! many responses ! :smiley: thanks DennyR, Ogniok and TheJamsh! i really needed that Help!
i will really work on the point 2 you all suggested me!
i know how actors work, my doubts were more focused on where should i put the logic of my game. i will work using only GameMode to implement the more general logic. my problem is that in my mind, GameMode, GameInstance and ULevel means nothing( i readed the Docs many times, many but i keep strugling trying to understand where to put things and the example projects from the market doesnt really help since almost all were made using BPs :frowning: ), i will keep things basic and work with my Actors, my Character Controllers, my Pawns and the GameMode(here i will implement the more general logic).

Denny and Ogniok said “The best way of doing it is just to implement all the components in C++ and then make a BlueprintSubclass of it. In the Blueprint you can edit the asset references easily.”

Correct me if i am wrong, but, if i do this i will end up doing my general game logic(the one that should be in AGameMode), using BPs, is this correct?, i wouldnt be able to spawn any actor from AGameMode in C++, so i will end using BPs with this aproach, right? . i feel like a bit resistant to the BP aproach but i will try, it is simply not my “habitat” :stuck_out_tongue: i am imagining colossal game logic using those graphical nodes, a big maze of nodes, i prefer mazes of code :smiley: ok, i am over exagerating heehe

Many thanks again guys , i appreciate you time! :smiley:

No. You don’t have to put your gameplay logic in blueprints. You can just reference assets you need and then use them in C++. This is how you can create a simple reference:
In the header of your class:



UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = "Assets") //Specifiers could differ of course
TSubclassOf<class AActor> MyObjectReference; //You can use your custom classes instead of AActor


In the source code of your class:



void AMyClass::SpawnMyObject(FVector Location, FRotator Rotation)
{
      if(MyObjectReference)
      {
            GetWorld()->SpawnActor<AActor>(MyObjectReference, Location, Rotation);
      }
}


If you create blueprint based on AMyClass then you will see MyObjectReference property as a field that you can edit and where you be able to reference any asset from the project that derives from AActor(because we have set AActor as base class). After you start the game and some code class SpawnMyObject function it will spawn the actor you have set in created blueprint in MyObjectReference property.

Ohh! :smiley: That was what i was needing!!! exactly that! i am happy hahahaha i will follow your steps Ogniok, thanks God you understood my english :stuck_out_tongue: :smiley:
My grandfather was from Poland :D, Many thanks again!

Hi The Argentine, good answers here :). I was a little resistant to BP at first to, but now im loving the c++/bp workflow.
Sorry for the offtopic: Are you from Argentina? :smiley: there isn’t a lot of people from here on the forums

Hi Alex! nice to see a compatriot :stuck_out_tongue: assuming the final ‘arg’ of your nickname :smiley: i never met a guy from Argentina related to UE4 O.o you are the first one. Add me on UE if you like, my nickname is like that “The Argentine” , i believe i sended you a request to UE