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"

Type name is not allowed and pointer to incomplete class type

After following a tutorial, I got this code:

include "PillSpawner.h"

include "Components/BoxComponent.h" #include "MagicPill.h" #include "Classes/Kismet/KismetMathLibrary.h" #include "Components/StaticMeshComponent.h"

// Sets default values APillSpawner::APillSpawner() { // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. PrimaryActorTick.bCanEverTick = true;

 SpawningVolume = CreateDefaultSubobject<UBoxComponent>(TEXT("SpawnVolumeBox"));
 RootComponent = SpawningVolume;

 // This establishes the item to spawn as a Magic Pill
 //ItemToSpawn = AMagicPill::StaticClass();


// Called when the game starts or when spawned void APillSpawner::BeginPlay() { Super::BeginPlay();



// Called every frame void APillSpawner::Tick(float DeltaTime) { Super::Tick(DeltaTime);


// This is a function that returns a random location in the volume FVector APillSpawner::GetRandomPointInVolume() { FVector Origin = SpawningVolume->Bounds.Origin; FVector Extent = SpawningVolume->Bounds.BoxExtent;

 return UKismetMathLibrary::RandomPointInBoundingBox(Origin, Extent);


void APillSpawner::SpawnPill() { if (ItemToSpawn != NULL) { UWorld* const World = GetWorld(); if (World) { FVector SpawnLocation = GetRandomPointInVolume(); FRotator SpawnRotation; SpawnRotation.Pitch = FMath::FRand() 360.0f; SpawnRotation.Roll = FMath::FRand() 360.0f; SpawnRotation.Yaw = FMath::FRand() * 360.0f;

         AMagicPill* SpawnedPill = World->SpawnActor<AMagicPill>(ItemToSpawn, SpawnLocation, SpawnRotation);


Though, for some reason "World->SpawnActor" doesn't work, since I get these errors:

E0393 pointer to incomplete class type is not allowed E0254 type name is not allowed

I don't have any errors at all on the MagicPill end, but there are multiple errors showing up on the Pill Spawner. I'd really appreciate it if someone came with a solution or something that could help. I assume that it has to do with what to include, but I can't find anything related to include.

Product Version: UE 4.20
more ▼

asked Oct 17 '18 at 09:09 AM in Using UE4

avatar image

8 2 2

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

Try including the world.h header to use the GetWorld function.

 #include "Engine/World.h"
more ▼

answered Oct 17 '18 at 09:30 AM

avatar image

Steve SybrSyn
1.5k 4 5 9

avatar image SkyChrome Oct 17 '18 at 10:45 AM

Well thank you! That worked, couldn't seem to find the correct header file, so thanks for the help! :)

avatar image Steve SybrSyn Oct 17 '18 at 10:50 AM

You are welcome, I'm glad I could help. If you could please mark my answer as correct to help others with a similar issue easily find the solution. Thank you :)

(comments are locked)
10|2000 characters needed characters left
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