GetOwner() Not Autocompleting

Hi! I’m new to UE4 development and I’ve followed Udemy’s Unreal Engine Development course. But unlike in those videos I can’t get Visual Studio to autocomplete GetOwner() members, functions. The only error I’m getting is Pointer to incomplete class type is not allowed when I hover GetOwner line.

I get the error for example when I try to use the code GetOwner()->GetName() or GetOwner()->GetTransform(). I don’t have any troubles when compiling or building everything works fine but for a starter like me autocomplete is a big help.(Without autocomplete it is a bit hard for me to complete the challenges in course videos, learn and get familiar with new classes.)

Note 1: I have tried including my project’s haeder file on top of everything but it didn’t help.

Note 2: From the comment’s in this question it seems this is a UE 4.16 related problem.

Any help is appreciated.

EDIT:

First of all thank you for all of your suggestions. After reading all the comments and the answers I followed your instructions and I’m sharing the results down below:

  • I installed Visual Assist. Now it is easier to read the code yet autocomplete problem persists.
  • I tried the SetOwner() solution proposed by DevDevy, even though code complies just fine I still can’t get autocomplete to work.
  • Note: I did restart everything and even tried to open the project as Administrator.

Also as mentioned by nachtmahr Pointer to incomplete class type is not allowed is not a compile error but I still think this error is related to the main autocomplete problem.

If no one else is having the same problem as me is it better for me to reinstall VS & UE4? (Please note that I created the development enviroment following the instrucions on Udemy Course)

Intellisense is wonky at best. Give Visual Assist a shot.

I have the same issue and would love to hear what’s going wrong… It’s a bit strange, as AActor class does not even have a Method called GetName(), but seems to inherit that from UObjectBaseUtility. Are we missing an import statement?

As mentioned by the author, the issue isn’t limited to autocomplete, but rather results in a compiler error "Pointer to incomplete class type is not allowed " as well!

Guys its Intellisense. Its not smart enough to figure out whats going on. Complain to MS =) otherwise like ExtraLifeMatt Answered use Visual Assist it does a great Job and comes with a bounch off additional great Features.

And if you want to Ask why does Epic not make everything Intellisense friendly. Don´t :stuck_out_tongue_winking_eye: (I spare myself the explanation it would be pages long, please understand ^^)

Seriously if you Code with C++ Visual Assist is the best investment you can make. And its relativly cheap (try the trial and lookup some advanced Features)

For those having errors not related to Intellisense, it may be because you haven’t set an Owner for your object. When you call GetOwner its methods are null. See the declaration: AActor* GetOwner() const; Hence the pointer to incomplete class error.

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

	ASpawnHelper* OwnerObject = NewObject<ASpawnHelper>(this);
	SetOwner(OwnerObject);
	FString ObjectName = GetOwner()->GetName();
	FString ObjectPos = GetOwner()->GetTransform().GetLocation().ToString();
	GEngine->AddOnScreenDebugMessage(-1, 1000, FColor::White, FString::Printf(TEXT("Object Name: %s"), *ObjectName));
	GEngine->AddOnScreenDebugMessage(-1, 1000, FColor::White, FString::Printf(TEXT("Object Pos: %s"), *ObjectPos));
}

In this example my Owner is ASpawnHelper* called OwnerObject.

Tried it! Same problem!!! Don’t get me wrong - beautiful colors, but still the same issue :slight_smile:

Don’t get me wrong - beautiful colors, but still the same issue

I don’t get it. If I add the component to an Object in the Editor, then this object is the owner, right? Why would I have to set that manually?

GetOwner returns an AActor, not a component. You can use it for network replication to handle client rendering, network relevancy, ect. So this would need to be set manually.

that error still comes from Intellisense :stuck_out_tongue_winking_eye: your Autocompletion works like expected?

Its not a Compiler error! You can Compile just fine =)

I updated my answer based on the comments and answers given. Please checkout the edit section.

I updated my answer based on the comments and answers given. Please checkout the edit section.

I updated my answer based on the comments and answers given. Please checkout the edit section.

Thanks everyone for your support on helping me solve this problem. I solved the autocomplete issue by adding #include “Engine.h” to the top of my header files. Appearantly having CoreMinimal included is not enoguh. I’m not sure if this was intended or just a mini bug but this method solved the problem for me.

Note: İncluding the Engine header file in only just ProjectName.h file is not enough for solving the autocomplete issue you need to add it in all header files where you are having this problem.

Golden! That does it, and no additional tools required! +1, +100 if I could :slight_smile:

many many many THANX !

Hi there, I had the same problem (UE 4.19) and found in documentation that the actual necessary header for autocomplete is “GameFramework/Actor.h”, so no need for huge “Engine.h” in your code.

See here: http://api.unrealengine.com/INT/API/Runtime/Engine/GameFramework/AActor/GetOwner/index.html

Hopefully this helps someone!

thank you! It’s really useful!