Download

UInstancedStaticMeshComponent is undefined

I’m working on a chunk generator actor and I’m pretty new in C++ so I’m having some problems…
I want to let myself add Instanced Static Mesh Components in the BP, so I tried this:



	UPROPERTY(EditAnywhere, BlueprintReadWrite)
		TArray <UInstancedStaticMeshComponent*> InstancesToUseInTheGenerator;


but it doesnt seem to work, “undefined” so I changed it to static meshes and then in OnConstruction I tried creating the actual instances component from this array but it’s still “undefined”…



	int S = 0;
	while (S < StaticMeshes.Num()) {
		InstanceMesh[S] = NewObject<UInstancedStaticMeshComponent>(this, name);
		InstanceMesh[S]->RegisterComponent();
		S++;
	}


Anyone knows how to make it work? Thanks :slight_smile:

You need to #include the correct .h file which is probably somewhere in /Components.

oh found it, thanks :smiley:
#include “InstancedStaticMeshComponent.generated.h”;

Got some time to mess with it now and I’m really confused from whats going on:

There are these 3 errors in #include, UCLASS() and class now…

No, no, you don’t include the .generated.h version, just the .h.

Still doesnt work and now there is also an error in it :confused:

Are you sure InstancedStaticMeshComponent.h is not in some subfolder? You need to provide the exact path if it’s not in UE/Runtime/Engine itself. (e.g. /Components/SplineMeshComponent.h)

Also about the underlines on UCLASS(), see: Unreal Engine 4 Intellisense for Visual Studios 2015 - UE4 AnswerHub