Unable to override functions in UPawnSensingComponent

UPawnSensingComponent has 2 virtual functions I want to override. Here’s my class:

class MYPROJECT_API UCancellaPawnSensingComponent : public UPawnSensingComponent
	virtual bool CouldSeePawn(const APawn* Other, bool bMaySkipChecks = false) const override;
	virtual void SensePawn(APawn& Pawn) override;

The CPP definitions:

bool UCancellaPawnSensingComponent::CouldSeePawn(const APawn* Other, bool bMaySkipChecks) const
//my code

void UCancellaPawnSensingComponent::SensePawn(APawn& Pawn)
	// my code

The problem is that when I use this class into my UCharacter subclass, the two functions do not seem to be overridden. The Super version is executed. I can also trigger breakpoints in the Super version of the function. Is there something I am doing wrong in the way I override the functions?

Edit: an update on the problem.

The problem disappears if I create the object in the constructor of my character as so:

SensingComponentPtr = CreateDefaultSubobject<UCancellaPawnSensingComponent>("MySensingComponent");

The problem is there if I create the object at runtime as so:

SensingComponentPtr = NewObject<UCancellaPawnSensingComponent>(this, SensingComponentPtr->StaticClass());

So I guess there is something about NewObject that I don’t understand.

I have found a solution, although I am not sure about the implications. Anyway, after using NewObject on SensingComponentPtr pointer I need to use RegisterComponent:


Hope this helps someone else.