Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

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

    Code:
     for (int i = 1; i < 9; i++)
    {
    FString yy = FPaths::GameDir();
    yy.Append("Content/Assets/Resources/").Append(FString::FromInt(i)).Append("_Sprite.").Append("Paper2DSprite_C");
    UClass* NowClass = ConstructorHelpers::FClassFinder<APaperSpriteActor>(yy.GetCharArray().GetData()).Class;
    TSubclassOf<APaperSpriteActor>NowClassA = NowClass;
    Classes.Add(NowClassA);
    }
    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.

    #2
    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.
    Able Ability System - A high performance, robust ability system for UE4. Now Available!

    Comment


      #3
      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.
      Click image for larger version

Name:	QQ截图20201021111001.png
Views:	76
Size:	71.0 KB
ID:	1824205
      So what path and name should I type?Please tell me,and I'll be thankful.

      Comment


        #4
        1.ConstrutorHelpers一定放在Constructor里,不要放在后面其他的方法中
        2.右键Sprite会有Get Reference,点击即可复制,掐头去尾即可使用

        Comment


          #5
          非常感谢。

          Comment


            #6
            I changed that period of code and now it becomes as following code:
            Code:
            for (int i = 1; i < 9; i++)
            {
            FString yy = "/Game/Assets/Resources/";
            yy.Append(FString::FromInt(i)).Append("_Sprite.").Append(FString::FromInt(i)).Append("_Sprite");
            UObject* NowObject = ConstructorHelpers::FObjectFinder<APaperSpriteActor>(yy.GetCharArray().GetData()).Object;
            UClass* NowClassA = NowObject->StaticClass();
            Classes.Add(NowClassA);
            }
            But the project still crashed and when I "send and restart",a message jumped out as following screenshot.
            :Click image for larger version

Name:	QQ截图20201021214657.png
Views:	65
Size:	29.9 KB
ID:	1824411

            Comment


              #7
              Originally posted by 歼轰20 View Post
              I changed that period of code and now it becomes as following code:
              Code:
              for (int i = 1; i < 9; i++)
              {
              FString yy = "/Game/Assets/Resources/";
              yy.Append(FString::FromInt(i)).Append("_Sprite.").Append(FString::FromInt(i)).Append("_Sprite");
              UObject* NowObject = ConstructorHelpers::FObjectFinder<APaperSpriteActor>(yy.GetCharArray().GetData()).Object;
              UClass* NowClassA = NowObject->StaticClass();
              Classes.Add(NowClassA);
              }
              But the project still crashed and when I "send and restart",a message jumped out as following screenshot.
              :Click image for larger version

Name:	QQ截图20201021214657.png
Views:	65
Size:	29.9 KB
ID:	1824411
              在非构造函数加载sprite而不是class的话,用LoadObject更灵活 ,例如LoadObject<UDataTable>(NULL, UTF8_TO_TCHAR("/Game/DATA/PMV_ATTACK_DEF.PMV_ATTACK_DEF"))

              Comment


                #8
                Originally posted by wzspdw View Post

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

                Comment


                  #9
                  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:
                  Click image for larger version

Name:	image_205604.png
Views:	46
Size:	327.7 KB
ID:	1825536
                  Click image for larger version

Name:	image_205605.png
Views:	42
Size:	288.4 KB
ID:	1825537So I wonder how I can change the property of mobility.Thanks if someone tells me.

                  Comment


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

                    Comment

                    Working...
                    X