How to update parent actor when USplineComponent point is moved?

Hey,

I have a USplineComponent as an actor’s RootComponent.

On that actor I have tried to override:
OnConstruction
PostEditChangeProperty
PostEditChangeChainProperty

but they don’t fire when USplineComponent is modified(when I move the spline points).

**How do I get a function to fire when my USplineComponent is modified in the editor?
I’m using version 4.7.2 (do I need to update?)
**

I did this in blueprints and it worked fine.

If you’re interested in the code:



APath::APath(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)
{
	Path = CreateDefaultSubobject<USplineComponent>(TEXT("Path"));
	RootComponent = Path;

	// Create billboard
	BillboardEnd = CreateDefaultSubobject<UBillboardComponent>(TEXT("BillboardEnd"));
	BillboardEnd->AttachTo(RootComponent);
}

void APath::UpdateBillboard()
{
	// Set billboard location
	FVector Loc;
	FVector Tang;
	Path->GetLocalLocationAndTangentAtSplinePoint(Path->GetNumSplinePoints()-1, Loc, Tang);

	BillboardEnd->SetRelativeLocation(Loc);
}

void APath::OnConstruction(const FTransform& Transform)
{
        // Not triggered when Path(USplineComponent) is changed
	UpdateBillboard();

	// Super
	Super::OnConstruction(Transform);
}

void APath::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
        // Not triggered when Path(USplineComponent) is changed
	UpdateBillboard();

	Super::PostEditChangeProperty(PropertyChangedEvent);
}

void APath::PostEditChangeChainProperty(struct FPropertyChangedChainEvent& PropertyChangedEvent)
{
        // Not triggered when Path(USplineComponent) is changed
	UpdateBillboard();

	Super::PostEditChangeChainProperty(PropertyChangedEvent);
}


This might sound a little silly, but did you make sure your version of OnConstruction is being called at all? I once forgot to declare “override” on my OnConstruction in the Header and it took me forever to realize that. Also, you should probably run Super::OnConstruction() before your UpdateBillboard() as that gave me some fits as well for some reason.

I did have override. Moved Super::OnConstruction() to the top.

OnConstruction is being fired on start and also after I undo.
When I undo PostEditChangeProperty get fired first, then OnConstruction.

P.S. I forgot to mention that I want this to work while in editing mode (not playing)
I also added it into the level directly from C++ Classes

Found it

While messing around with other stuff I found the answer to this.

These 2 overrides are needed:



// The most important. Did not know this existed :)
void APath::PostEditMove(bool bFinished)
{
	Super::PostEditMove(bFinished);
	UpdateBillboard();
}

void APath::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
	Super::PostEditChangeProperty(PropertyChangedEvent);

	UpdateBillboard();
}