Access variables from another class

Hello guys. I’m having a problem to access variables from another class. Here is my code:

PooledObjects.h

#pragma once

#include "CoreMinimal.h"
#include "ObjectPooler.h"
#include "PooledObjects.generated.h"

/**
 * 
 */
UCLASS()
class PROGRAMMING_TEST_API APooledObjects : public AObjectPooler
{
	GENERATED_BODY()
	
	virtual void BeginPlay() override;

public:
	APooledObjects();
	
	UPROPERTY()
	class UStaticMeshComponent* Nicro;

	UPROPERTY(EditAnywhere)
	float MinLifespan;

	UPROPERTY(EditAnywhere)
	float MaxLifespan;

	UPROPERTY(EditAnywhere)
	AActor* Life;
	
	
};

PooledObjects.cpp

void APooledObjects::BeginPlay()
{
	Super::BeginPlay();

	ASpawner* LifeRef = Cast<ASpawner>(Life);
	if (LifeRef)
	{
		MinLifespan = LifeRef->MinLifetime;
		MaxLifespan = LifeRef->MaxLifetime;
		SetLifeSpan(FMath::FRandRange(MinLifespan, MaxLifespan));
	}

Spawner.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Spawner.generated.h"

UCLASS()
class PROGRAMMING_TEST_API ASpawner : public AActor
{
	GENERATED_BODY()

public:
	// Sets default values for this actor's properties
	ASpawner();

	virtual void Tick(float DeltaTime) override;



protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:
	// Called every frame

	FORCEINLINE class UBoxComponent* GetCollisionBox() const { return CollisionBox; }

	UFUNCTION()
		FVector GetRandomPointInVolume();

	UPROPERTY(EditAnywhere)
		float MinLifetime;

	UPROPERTY(EditAnywhere)
		float MaxLifetime;

	UPROPERTY(EditAnywhere)
		AActor * Life;
};

I’m trying to access MinLifespan and MaxLifespan in PooledObjects class from Spawner class so that i could edit the value anytime i want. Please show me what’s wrong with this code. Thank you in advance.

Are you getting any compilation errors?

None. I got no errors. Just the variables not passing to the PooledObjects. Is there any mistakes in my code?

What do you mean by “the variables not passing to the PooledObjects”?

Sorry. I mean whenever i change the MinLifetime/MaxLifetime value in the Spawner, the value will be pass to the MinLifespan/MaxLifespan in PoolObjects. But seems it’s not working.

And how will the value be passed to the MinLifeSpan/MaxLifeSpan in PoolObjects?