Value of Uproperty returning to 0 after edit?

Hi everyone, I must say that the confusion is real.

I am new to C++ so it might be me not understanding some concept but still this is weird.
I have a class that inherit uinstanceStaticMeshComponent with some Uproperty for number of instances etc.
When I change my Uproperty, blueprint or editor the value always return to 0 in my class.

So I tried to use the PostEditChangeProperty so I can watch the value and I see it change properly but then the constructor is called and the value is back to 0. I can do the updates in the postedit and it works but then my class return to default which seems like an undefined behaviour to me since I might need to access those attributes later.
My understanding of the situation is that the class is being recreated every time but is it supposed to be a actual behaviour? Or is it me who don’t understand something huhu

I saw a lot of post resolving around this and tried alot of things like setting values in constructor and all but nothing is working but again maybe it’s suppose to be like this ?
I wondered if I had to do a destructor too?

Here is my .h :

#pragma once

#include "MapGen.h"

#include "CoreMinimal.h"
#include "Components/InstancedStaticMeshComponent.h"
#include "TerrainScatter.generated.h"

struct FScatterParm

	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Scattering Parameters")
		FString name;

	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Scattering Parameters")
		int amount;

	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Scattering Parameters")
		FVector normal;

UCLASS(Blueprintable, ClassGroup=(Scatter), hidecategories = ("Instances"), meta = (BlueprintSpawnableComponent)) 
class POWER_API UTerrainScatter : public UInstancedStaticMeshComponent

	//virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;

	UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Scattering Parameters")
		FScatterParm scatterParms;

	TArray<float> terrainData;
	TArray<FVector> vertices;
	TArray<FVector> normals;

	AMapGen* pParentTerrain;
	MeshData* pTerrainData;

	void setTerrainData(TArray<FVector> &terrainVertices, TArray<FVector> &terrainNormals);
	TArray<float>& getTerrain();
	void update();

Here is the .cpp

#include "TerrainScatter.h"

	pParentTerrain = Cast<AMapGen>(this->GetOwner());

/*void UTerrainScatter::PostEditChangeProperty(struct FPropertyChangedEvent& e)

TArray<float>& UTerrainScatter::getTerrain()
	return terrainData;

void UTerrainScatter::setTerrainData(TArray<FVector> &terrainVertices, TArray<FVector> &terrainNormals)
	vertices = terrainVertices;
	normals = terrainNormals;

void UTerrainScatter::update()
	if (pParentTerrain)
		pTerrainData = pParentTerrain->getTerrainData();

	if (pTerrainData)
		setTerrainData(pTerrainData->vertices, pTerrainData->normals);
		UE_LOG(LogTemp, Log, TEXT("pTerrainData is not null"));
		if (vertices.Num() != 0) {
			UE_LOG(LogTemp, Log, TEXT("current value : %i"), scatterParms.amount);
			for (int x = 0; x < scatterParms.amount; x++)
				int index = FMath::RandRange(0, vertices.Num() - 1);
				FVector pos = vertices[index];
				FVector normal = normals[index];

				if (normal.Y > scatterParms.normal.Y)
					FRotator rot = FRotator(0, 0, 0);
					float rand = FMath::FRandRange(.1, 1);
					FVector scale = FVector(rand, rand, rand);
					FTransform transform = FTransform{ rot, pos, scale };
		UE_LOG(LogTemp, Log, TEXT("pTerrainData is null"));

If you see anything else fishy go for it I’m here to learn !

Thanks for your help !
Confusion is confused.

Ahaha well it’s something thank you. I have to check what exactly UPProperty is for anyway but do I need it always? I thought UPROPERTY was for external access

Not the solution: Put UPROPERTY macro to pParentTerrain and also to pParentTerrain. If you really want to call the destructor use BeginDestory (and/or FinishDestory) instead.

Few things about UP - can be useful:
Automatic Updating of References: Unreal Object Handling | Unreal Engine Documentation

That’s some very nice doc thank you I’ll take a look, maybe it will fix my issue ^^