Owner claimed to be "AActor" when it should not be

When trying to get reference (pointer, actually) to parent/owner:

APlayer_Obj* PlayerCharacter = GetOwner();

I get this error:

a value of type "AActor *" cannot be used to initialize an entity of type "APlayer_Obj"

I have set the owner/parent in the class to be “APlayer_Obj” like this:

class TESTGAME_API APlayerChildClass : public APlayer_Obj

Yet it treats the “GetOwner()” as if APlayerChildClass is directly the child of Actor, to my understanding. Why is it doing this? I need to get a reference of the actual parent/owner that I’ve set, how can I do this?

Try casting it this way:

APlayer_Obj* PlayerCharacter = Cast<APlayer_Obj>(GetOwner());

Just make sure you check that GetOwner() is valid (not null).

Interesting, but why would owner be AActor by default and not APlayer_Obj as I’ve set it? Or do I not understand something about parenting correctly? Putting “APlayer_Obj” at the end of this line would make it the owner, no?

class TESTGAME_API APlayerChildClass : public APlayer_Obj

Because GetOwner() was declared as AActor in Actor.h (see below):

/**
 * Get the owner of this Actor, used primarily for network replication.
 * @return Actor that owns this Actor
 */
UFUNCTION(BlueprintCallable, Category=Actor)
AActor* GetOwner() const;

That just makes things a bit more confusing. Is the parent/owner class changed to the class that I define in the line I mentioned before? Is parenting different for classes and actual object instances that are being created? Because my main point here is to have this code be child of the player class in some form and have it be able to reference the player object so it can apply changes to the player object.

It’s hard for me to explain without looking at your APlayer_Obj’s .H file. I’m guessing your APlayer_Obj’s parent class is AActor and it inherits the GetOwner() function of AActor? So by default GetOwner() is AActor until you cast it to a specific class that has a base parent of AActor.