How can I resolve some Spawn Actor problems from BluePrint Editor?

Hello
Im trying to create this,

The issue i am currently having is spawning the first Actor, i have read many helpful things and used the creation of a projectile from the first person code as a reference.

So i need to be able to select a moduleBP with geometry for a room inside it from the blueprint editor, and have it spawn on BeginPlay. i then need to access that spawned actor later in the code

At first i had this code inspired by the projectile code.
Where AModule is a Actor class.

.h

#pragma once

#include "GameFramework/Actor.h"
#include "Module.h"
#include "DungGen.generated.h"

/**
 * Spawns the dungeon based vars givin to it.
 */
UCLASS(dependson = AModule)
class ADungGen : public AActor
{
	GENERATED_UCLASS_BODY()

	//Public vars editable to editor.

	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Generation")
	int16 Iterations;

	UPROPERTY(VisibleAnywhere, Category = "SphereCore")
	TSubobjectPtr<USphereComponent> SphereCore;

	/** Start Module to spawn */
	UPROPERTY(EditDefaultsOnly, Category = "Generation")
	TSubclassOf<class AModule> StartModule;

	UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = BPClasses)
	UClass* YourBuildingBP;

	UPROPERTY(EditDefaultsOnly, Category = "Generation")
	TArray<class AModule*> Modules;

	
	virtual void BeginPlay();
};

.cpp

#include "LevelGen.h"
#include "DungGen.h"


ADungGen::ADungGen(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	//Iterations = 5;
	SphereCore = PCIP.CreateDefaultSubobject<USphereComponent>(this, TEXT("SphereCore"));
	SphereCore->InitSphereRadius(35.0f);
	RootComponent = SphereCore;

	//StartModule = nullptr;
}



void ADungGen::BeginPlay()
{

	Super::BeginPlay();

	if (StartModule != NULL)
	{
		const FRotator SpawnRotation = this->GetActorRotation();

		const FVector SpawnLocation = GetActorLocation();

		UWorld* const World = GetWorld();

		if (World != NULL)
		{
			// spawn the module
			AModule* newmod = World->SpawnActor<AModule>(StartModule, SpawnLocation, SpawnRotation);
		}
	}
	

}

This returns the error

use of undefined type ‘AModule’ C:\Program Files\Unreal Engine\4.1\Engine\Source\Runtime\CoreUObject\Public\UObject\Class.h

Mmmmm

Then after reading some advice on here, i followed Something Rama said i believe:

.h

UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = BPClasses)
 UClass* YourBuildingBP;

.cpp

if (YourBuildingBP != NULL)
{
	const FRotator SpawnRotation = this->GetActorRotation();

	const FVector SpawnLocation = GetActorLocation();

	UWorld* const World = GetWorld();

	if (World != NULL)
	{
		// spawn the module
		World->SpawnActor<AModule>(YourBuildingBP, SpawnLocation, SpawnRotation); //Returns a error.
	}
}

All help would be very much appreciated!

you’ll need to post more code for anyone to help you

Please post your AModule.h class header

And the entire .h file for your main function you copied portions of above.

#Dependson

also sounds like your current class needs to depend on AModule.h

UCLASS(dependson=AModule)

Rama

From my understanding of Dependson, it makes the compiler compile the specified file before our original class that is depended compiles. In my case this worked perfect! Thanks Rama for your time!