Melvin Vasquez
Melvin Vasquez

Reputation: 11

How to fix "Pointer to Incomplete class type is not allowed" error in Unreal Engine 4

I'm trying to learn C++ using a book called "Learning C++ by Creating Games with Unreal Engine 4" by Sharan Volin. Up to this point, I had been following the examples, but I got stuck at this error, despite the fact that I'm typing everything verbatim from the text. Is there something I am missing or not understanding?

I've tried to see if there were any other guides or Git Repos on this exercise, but had no luck. Other Stack user questions regarding error code E0393 (the error I'm getting) don't seem to help, as I have the Avatar.h file included in the Avatar.cpp file.

This is the code in the segment in the Avatar.cpp file giving me an error, specifically the last two lines that start as PlayerInputComponent->

// Called to bind functionality to input
void AAvatar::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
check(PlayerInputComponent);
PlayerInputComponent->BindAxis("Forward", this, &AAvatar::MoveForward);
PlayerInputComponent->BindAxis("Strafe", this, &AAvatar::MoveRight);
}

This is some of the code present in the Avatar.h file, with only the last 4 lines being what I was instructed to type in.

public: 
    // Called every frame
    virtual void Tick(float DeltaTime) override;

    // Called to bind functionality to input
    virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

    //New! These 2 new member function declarations
    //they will be used to move our player around!
    void MoveForward(float amount);
    void MoveRight(float amount);
};

The final result should allow me to move an avatar in the Unreal Project forward and to the right upon pressing "W" and "D" respectively. However, in the Avatar.cpp file, I get the error E0393 pointer to incomplete class type is not allowed. I also never get the project to launch in the Unreal Editor.

Upvotes: 1

Views: 16469

Answers (2)

Groshh
Groshh

Reputation: 160

In your cpp file as you have forward declared the class. You need to have the include for the actual definition in the .cpp file. So you need to have the include for the UInputComponent.

On the docs for the Component: here you will see at the bottom of the page it's location in the engines files.

#include "Components/InputComponent.h"

Upvotes: 1

david fotsing
david fotsing

Reputation: 21

simply go to your header file "Avatar.h" and type #include "Components/InputComponent.h"

Upvotes: 2

Related Questions