SetChildActorClass does not replace the child but creates a new one

I have a problem with the “SetChildActorClass” function both in c ++ and in BP version.
When I call the node for every other class, the child actor is replaced with a new actor from the new class.
However, this does not happen for a particular class in C ++, where by calling the node, instead of replacing the class, new actors are created.

349483-screenshot-83.png

this is what the child actor looks like:

the class is a c ++ class and is the only non-working c ++ class.

C_Gun.h

#pragma once

    #include "CoreMinimal.h"
    #include "GameFramework/Actor.h"
    #include "Components/StaticMeshComponent.h"
    #include "Components/AudioComponent.h"
    #include "C_Gun.generated.h"
    
    UCLASS()
    class THE_TOP_MOBILE_API AC_Gun : public AActor
    {
    	GENERATED_BODY()
    	
    public:	
    	// Sets default values for this actor's properties
    	AC_Gun();
    	UPROPERTY(VisibleAnywhere)
    		UStaticMeshComponent* GunMesh; //CreaUnaVariabileVisualMesh
    	UPROPERTY(VisibleAnywhere)
    		UAudioComponent* Shoot_Cue; 
    	UPROPERTY(VisibleAnywhere)
    		UAudioComponent* Reload_Cue;
    
    	//Variables
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings")	//Indica il tipo di arma, serve a selezionare l'animazione dell'arma
    		int GunType;
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings")	//Munizioni massime dell'arma
    		int MaxAmmo = 1;
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings")	//Velocità a cui spara l'arma
    		float FireRate = 1.0;
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings")	//Velocità di ricarica
    		float ReloadSpeed = 1.0;
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings")	//Velocità dell'attore con l'arma in mano (Camminata)
    		float WalkingSpeed = 200;
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings")	//Velocità dell'attore con l'arma in mano (Corsa)
    		float RunningSpeed = 200;
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings")	//Danno dell'arma
    		float BulletDamage = 10;
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings")	//Range dell'arma
    		float GunRange = 1000;
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings")	//Prezzo dell'arma
    		float GunPrice = 1000;
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Runtime")	//Referenza al possessore dell'arma
    		class AC_HumanCharacter* OwnerRef;
    
    	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings")	//Indica il tipo di arma, serve a selezionare l'animazione dell'arma
    		UAnimMontage* ReloadMontage;
    	
    
    		int CurrentAmmo;
    		bool IsShooting = false;
    		bool CooldownActive = false;
    
    	UFUNCTION(BlueprintCallable)
    		void StartShooting();
    
    	UFUNCTION(BlueprintCallable)
    		void StopShooting();
    
    	UFUNCTION(BlueprintCallable)
    		void Reload();
    
    	void Cooldown();
    
    
    
    
    protected:
    	// Called when the game starts or when spawned
    	virtual void BeginPlay() override;
    	FTimerHandle LoopTimer;
    	void Shoot();
    
    public:	
    	// Called every frame
    	virtual void Tick(float DeltaTime) override;
    
    };

C_Gun.cpp

#include "C_Gun.h"
#include "C_HumanCharacter.h" 
#include "GameFramework/Character.h"
#include "DrawDebugHelpers.h"



// Sets default values
AC_Gun::AC_Gun()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = false;
	GunMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("GunMesh"));
	GunMesh->SetupAttachment(RootComponent);
	GunMesh->SetCollisionProfileName(TEXT("NoCollision"));
	Shoot_Cue = CreateDefaultSubobject<UAudioComponent>(TEXT("ShootCue"));
	Shoot_Cue->bAutoActivate = false;
	Reload_Cue = CreateDefaultSubobject<UAudioComponent>(TEXT("ReloadCue"));
	Reload_Cue->bAutoActivate = false;
}

void AC_Gun::StartShooting()
{
	if (!IsShooting)
	{
		    IsShooting = true;

			if (!CooldownActive)
			{
				Shoot();
			}
			//GetWorldTimerManager().SetTimer(LoopTimer, this, &AC_Gun::Shoot, FireRate, true, 0.0f);
	}
}

void AC_Gun::StopShooting()
{
	IsShooting = false;
}

void AC_Gun::Reload()
{
	CooldownActive = true;
	Reload_Cue->Play();
	OwnerRef->PlayAnimMontage(ReloadMontage, 1, NAME_None);
	//completare
	CurrentAmmo = MaxAmmo;
	GetWorldTimerManager().SetTimer(LoopTimer, this, &AC_Gun::Cooldown, 0.1f, false, ReloadSpeed); //<-RELOAD TIME
	//StartShooting();
}

void AC_Gun::Cooldown()
{
	CooldownActive = false;
	if (IsShooting)
	{
		Shoot();
	}
}

void AC_Gun::Shoot()
{
	if (CurrentAmmo > 0)
	{
		CooldownActive = true;
		//RilevaMinacciaAI();
		Shoot_Cue->Play();
		CurrentAmmo --;
		//LineTrace
		FHitResult OutHit;
		FVector Start = this->GetActorLocation();
		FVector End = Start + (this->GetActorForwardVector() * GunRange);
		FCollisionQueryParams CollisionParams;
		CollisionParams.AddIgnoredActor(this);
		CollisionParams.AddIgnoredActor(OwnerRef);
		DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1, 0, 1);
		bool IsHit = GetWorld()->LineTraceSingleByChannel(OutHit, Start, End, ECC_Visibility, CollisionParams);
		if (IsHit)
		{
			if (OutHit.bBlockingHit)
			{
				//damage event
				GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Blue, FString::Printf(TEXT("%s"), *OutHit.GetActor()->GetName()));
				FDamageEvent DamageEvent;
				OutHit.GetActor()->TakeDamage(BulletDamage, DamageEvent , this->GetInstigatorController(), this);
			}
		}
		//MakeNoise (completare)
		GetWorldTimerManager().SetTimer(LoopTimer, this, &AC_Gun::Cooldown, 0.1f, false, FireRate);
	}
	else Reload();
}

// Called when the game starts or when spawned
void AC_Gun::BeginPlay()
{
	CurrentAmmo = MaxAmmo;
}

// Called every frame
void AC_Gun::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

Problem solved, I ran some tests trying to delete only the actor class.
Apparently the Destroy () event didn’t work, so infinite classes were created.
The mistake was due to the fact that I didn’t put “Super :: BeginPlay ()” in the weapon class.