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"

Crash in game mode with InstancedStaticMesh as RootComponent

Hi community,

I am new in Unreal programming so please forgive the probably evidence of my question.

I am doing some tests with InstancedStaticMesh that seems to work quite good in editor mode, but crash in GameMode (Play in the editor). Could you explain to me why please?

Crash happens when i replace the Floor->AttachTo(RootComponent) by RootComponent = Floor;

Is it forbidden to have an InstancedStaticMesh as RootComponent? The crash seems to happen when trying to get a Body for something (debug assertion).

Thanks for your time.

 UCLASS()
 class TEST_API AMeshSet : public AActor
 {
     GENERATED_BODY()
 public:
 
     /** a static Mesh  */
     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Test)
         UInstancedStaticMeshComponent* Floor;
 
 
     /** a static Mesh  */
     UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Test)
         UInstancedStaticMeshComponent* Pillar;
 
     AMeshSet(const FObjectInitializer& ObjectInitializer);
 
     UFUNCTION(BlueprintCallable, Category = Dungeon)
     void Reconstruct();
 
 };
 

 AMeshSet::AMeshSet(const class FObjectInitializer& PCIP)
 : Super(PCIP)
 {    
     Floor = PCIP.CreateDefaultSubobject<UInstancedStaticMeshComponent>(this,TEXT("Floor"));
     static ConstructorHelpers::FObjectFinder<UStaticMesh> floorStaticMesh(TEXT("StaticMesh'/Game/StarterContent/Architecture/Floor_400x400.Floor_400x400'"));
     Floor->StaticMesh = floorStaticMesh.Object;
     // RootComponent = Floor;
     Floor->AttachTo(RootComponent);
 
     Pillar = PCIP.CreateDefaultSubobject<UInstancedStaticMeshComponent>(this, TEXT("Pillar"));
     static ConstructorHelpers::FObjectFinder<UStaticMesh> pillarStaticMesh(TEXT("StaticMesh'/Game/StarterContent/Architecture/Pillar_50x500.Pillar_50x500'"));
     Pillar->StaticMesh = pillarStaticMesh.Object;
     Pillar->AttachParent = RootComponent;
   
     Reconstruct();
 }


Product Version: Not Selected
Tags:
more ▼

asked Feb 03 '15 at 12:44 PM in C++ Programming

avatar image

Daes
36 1 2 8

avatar image MickD777 Feb 03 '15 at 01:53 PM

InstancedStaticMesh purpose is to render multiple instance of the same static mesh efficiently. It would make for a poor RootComponent in my opinion!

Maybe what you want to do is to have a StaticMeshComponent as your root?

Try UStaticMeshComponent instead of UInstancedStaticMeshComponent.

avatar image Daes Feb 03 '15 at 02:59 PM

Hi Michael, Thanks for answer.

I use InstancedStaticComponents to instantiate StaticMeshes in the Reconstruct function.

Putting this kind of component as root crash the game (not the editor). I have no use of StaticMesh as root but following your advice, i tried: - A empty StaticMeshComponent but it crashes too. - A USceneCompoent, as is (used like a empty) and it works as Root.More it resolves some instanciation performance problem i had with my first solution (No RootComponent defined)

Thanks for putting me in the rails.

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

0 answers: sort voted first
Be the first one to answer this question
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