Trying to get class successfully :(


I have this in the.h file:

TSubclassOf < AActor > tankClass;

and this in BeginPlay() (.cpp file)

tankClass = LoadClass(nullptr, TEXT(“Blueprint’/Game/TankBP.TankBP’”));

when i check tankClass it is always nullptr :frowning:

Blueprint’/Game/TankBP.TankBP’ <— this is the reference copied from editor

What i am doing wrong?

solved by replacing:




W H Y ! ? ! ?

becuase “_C” is the class.

Isn’t it obvious?

This is a package:


This is a blueprint


And this is a class:


Use the first to do poackage things. The second to do Blueprint Things. But you need a class to Create real objects in game.

Its confusing in the editor. It wont show you the _C excepot when simulating. Turn your TSubclass into a UPROPERTY with a pulldown. THen look at what you get in code when you set it and ask it for what class it has…

1 Like

Hey! thank you very much for the expllanation. It is obvious once you know it because I was literally hours to figure it that needed add the _C when referencing classes.

Thanks again!