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:

http://image.prntscr.com/image/1e9dce43960a4fda8a807cd2b8668a0d.png

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

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

http://image.prntscr.com/image/a877f5b144104be6be824820bca8280f.png

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: https://answers.unrealengine.com/questions/348068/unreal-engine-4-intellisense-for-visual-studios-20.html