x

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"

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)

Product Version: UE 4.16
Tags:
more ▼

asked May 27 '17 at 09:44 AM in C++ Programming

avatar image

AyazmonI
46 2 5 17

avatar image ChrisVomRhein May 27 '17 at 04:23 PM

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?

avatar image Nachtmahr May 27 '17 at 05:13 PM

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 ;P (I spare myself the explanation it would be pages long, please understand ^^)

avatar image Nachtmahr May 27 '17 at 05:14 PM

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)

https://www.wholetomato.com/learn/top10.asp

avatar image ChrisVomRhein May 27 '17 at 06:07 PM

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

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

code.png (8.6 kB)
avatar image Nachtmahr May 27 '17 at 07:16 PM

that error still comes from Intellisense ;P your Autocompletion works like expected?

avatar image AyazmonI May 27 '17 at 10:03 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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.

more ▼

answered May 27 '17 at 10:22 PM

avatar image

AyazmonI
46 2 5 17

avatar image ChrisVomRhein May 28 '17 at 04:26 PM

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

avatar image polimeraus 6 days ago

many many many THANX !

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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));
 }
 

alt text

In this example my Owner is ASpawnHelper* called OwnerObject.

owner.png (359.1 kB)
more ▼

answered May 27 '17 at 06:23 PM

avatar image

DevDevy
44 1 2 5

avatar image ChrisVomRhein May 27 '17 at 06:44 PM

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?

avatar image DevDevy May 27 '17 at 07:19 PM

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.

avatar image AyazmonI May 27 '17 at 10:03 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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

more ▼

answered May 27 '17 at 03:53 PM

avatar image

ExtraLifeMatt
1.2k 31 7 40

avatar image ChrisVomRhein May 27 '17 at 05:11 PM

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!

avatar image Nachtmahr May 27 '17 at 07:16 PM

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

avatar image AyazmonI May 30 '17 at 01:45 PM

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

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