# Why do I get “UObject” has no member “BeginPlay” errors?

I loaded up UE4 to work on a new project. I created two C++ classes, one for a bullet, one for a cannon. Upon loading into Visual Studio 2015 I immediately get the error:

"UObject" has no member "BeginPlay"

Keep in mind I have not written a single line of code. This error just popped up. I have not written a single comment, a single variable, I don't even get to enter some white space so that I have room for new code. I just get the error. I tried remaking the project with different settings (like a blank project, third person, et cetera) and I keep getting that error.

"UObject" has no member "BeginPlay"

That's because UObject doesn't have a BeginPlay member. BeginPlay comes from AActor.

It sounds like your bullet class just tries to inherit UObject directly, instead of AActor. If you want to make an actor subclass, your class needs to look like:

UCLASS()
class ABullet : public AActor {
...
}


Then you can implement BeginPlay, and call it on instances of your ABullet. User-error or possibly a bug in the C++ class creator in Unreal could have generated the type with the wrong base class as well, as it sounds like you didn't manually type it in.

Getting the error "immediately" suggests it's an error by the Intellisense parser, which... isn't really well suited to Unreal's massive codebase. It will often produce false positives and as such you may want to consider disabling the Intellisense feature that tries to pre-emptively pop-up errors and provide red squiggly underlines.

Unreal's unity compilation module will generally cause the headers for AActor to be pulled in for you, but if you're not using the unity builds or if Intellisense still refuses to co-operate (since it will not understand the unity builds) you can sometimes appease it by explicitly adding an #include "AActor.h" to the top of the file.

• I would also like to add one more thing which i came across recently. If your header class functions has some problems then it wont compile and will give above error. For me it was during defining ColliderEnter(). The paramters seems to be changed from the tutorials which i was watching. It was quite troublesome to figure out how the error was coming for. – killer_mech Nov 3 '17 at 21:40

This is a weird intellisense bug that in my case started happening when I added this include to my header file:

#include "PhysicsEngine/PhysicsHandleComponent.h"


What fixed it was a mix of 3 things I believe:

1. I deleted extra blank lines between my last include statement and my first line of code so that there is only ONE blank line between them. I changed from this:

to this:

2. I deleted spaces at the end of include statements. Sometimes when you copy paste include statements from the Unreal docs it adds extra spaces or new lines at the end, just make sure you delete those.

3. I reordered the include statements in my file. You might have to keep tweaking the order of your include statements until it gets fixed since I couldn't find a specific pattern that fixed it. The only thing I can say is make sure that generated.h" is at the bottom, and if you use CoreMinimal.h make sure it's at the top. Then tweak the order of what's in between.

In my case it was just an intellisense problem though so you would still be able to compile without errors if it's the same cause.

In this thread other people seem to also experience the issue being caused by the include statements