x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Assertian failed during SetStaticMesh call

While calling SetStaticMesh in my C++ code I receive assertions like this for several of my fbx files:

Engine\Source\Runtime\Core\Public\Containers\Array.h(536): Assertion failed: (Index >= 0) & (Index < ArrayNum) Array index out of bounds: 8 from an array of size 5

In my use case I need to import the fbx file at runtime without combining its meshes. They are about 1000 meshes, not 5 as the assertion suggests. This fbx file is already imported in the Editor, all 1000 static meshes are shown in the Content Browser and by selecting them all and drag&drop them into the scene I can see the model.

I want to reach the same effect when loading the assets from C++ code.

Import options I used:

alt text

The code snippet I use for setting a staticMesh:

ConstructorHelpers::FObjectFinder staticMesh(*assetName); m_meshes.getComponents().Add(PCIP.CreateAbstractDefaultSubobject(this, *assetName)); m_meshes.getComponentAtPos(i)->SetStaticMesh(staticMesh.Object);

Product Version: Not Selected
Tags:
more ▼

asked Sep 12 '14 at 08:13 AM in C++ Programming

avatar image

cubusfx
13 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Where are you doing this line:

 ConstructorHelpers::FObjectFinder staticMesh(*assetName); 

It will need to be in the constructor which I'm assuming your doing as your also using the PCIP. Also, "8 from an array of size 5" may be due to the "getComponentAtPos(i)", what can your 'i' variable go up to, it may be that it is trying to access a component that doesn't exist.

more ▼

answered Sep 12 '14 at 08:49 AM

avatar image

Dune
1.9k 53 40 200

avatar image cubusfx Sep 12 '14 at 09:40 AM

This was the problem. The mesh names contain numbers but they are not named consecutively which caused my indexing into the array to be wrong.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Yes, the code is inside the constructor of a subclass of AActor. The i variable can go from 0 to the total size of the meshes inside the fbx file which are hundreds. Inside the the class I have a class member variable m_meshes of custom type FSubObjStruct which allows me to manage subobjects in a TArray:

USTRUCT() struct FSubObjStruct { GENERATED_USTRUCT_BODY()

 UPROPERTY(VisibleAnyWhere, Category = "My Component")
 TArray<TSubobjectPtr<UStaticMeshComponent>> m_components;

 int32 getCount() const
 {
     return m_components.Num();
 }

 TSubobjectPtr<UStaticMeshComponent> getComponentAtPos(int32 idx)
 {
     return m_components[idx];
 }

 TArray<TSubobjectPtr<UStaticMeshComponent>>& getComponents()
 {
     return m_components;
 }

 FSubObjStruct()
 {
 }

};

more ▼

answered Sep 12 '14 at 09:10 AM

avatar image

cubusfx
13 1 4

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question