this->GetOwner inside if statement returns null?

So I am having a strange issue, I have an if statement that checks if a primitive component’s owner is the same as this actor’s Owner. I found a solution but want to know why the other way isn’t working for educational reasons :smiley:

AActor* OtherOwner = InComp->GetOwner();
AActor* ThisOwner = this->GetOwner();

if(OtherOwner == ThisOwner)

This succeeds(this is my solution) ^

if(InComp->GetOwner() == this->GetOwner())

This fails ^

You would cast to the class you want and declare it as in input in the function.

void SampleFunction(SampleClass* Sample)

Sample = Cast <SampleClass> (GetOwner());

Assuming it’s an attached component that is

Thats not what I’m asking, plus its not the only thing I’m doing inside of my function… I’m just asking why the second bit of code doesn’t work while the first one does even though they are basically the same thing.

Oh, my bad, I thought since they were both the same thing that you meant that part just wasn’t working.

Yeah since they’re the same thing, thats confusing part that I’ve been trying to find an answer to.