There is always the same crash report no matter how I change this period of code.

 for (int i = 1; i < 9; i++)
FString yy = FPaths::GameDir();
UClass* NowClass = ConstructorHelpers::FClassFinder<APaperSpriteActor>(yy.GetCharArray().GetData()).Class;
TSubclassOf<APaperSpriteActor>NowClassA = NowClass;

I’m trapped here for several days and have been searching useful data on the Internet till now.Who can tell me how to solve the problem?I’ll appreciate it if anyone helps me.

You should probably post the problem you’re getting and what you’re trying to do. I assume you’re trying to reference 9 sprites and add them all to a class array (which really doesn’t make sense)?

So, here’s where you can be going wrong:

  1. The path you are constructing is invalid (so ClassFinder returns null). You should check that NowClass isn’t nullptr.

  2. You can use Cast<APaperSpriteActor> instead of TSubclassOf to do your casting.

Also it should be noted that you are loading CLASSES here and not OBJECTS. So, unless you have 9 different classes that all inherit from Paper2DSprite_C and plan to instance them later - I’m not sure what you’re going for.

I just wonder how I can write down the right path and **the right file name.**I create 8 different classes and want them to be the classes of the sprites in the following screenshot.I only know that if I pull the sprites into the scene,they’ll be APaperSpriteActors.

So what path and name should I type?Please tell me,and I’ll be thankful.

2.右键Sprite会有Get Reference,点击即可复制,掐头去尾即可使用


I changed that period of code and now it becomes as following code:

for (int i = 1; i < 9; i++)
FString yy = "/Game/Assets/Resources/";
UObject* NowObject = ConstructorHelpers::FObjectFinder<APaperSpriteActor>(yy.GetCharArray().GetData()).Object;
UClass* NowClassA = NowObject->StaticClass();

But the project still crashed and when I “send and restart”,a message jumped out as following screenshot.

在非构造函数加载sprite而不是class的话,用LoadObject更灵活 ,例如LoadObject<UDataTable>(NULL, UTF8_TO_TCHAR("/Game/DATA/PMV_ATTACK_DEF.PMV_ATTACK_DEF"))


Now the program is able to run,but I can’t see the APaperSpriteActor actors,and when I finish it,the warnings jumped out as following screenshots:
image_205605.pngSo I wonder how I can change the property of mobility.Thanks if someone tells me.

Could someone help me with the newest problem?I’ve searched the data about it on the Internet,but there’s nothing about it.