Problem with using custom class as a variable in another class

Hi all,

I created this class:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "State.generated.h"


UCLASS(Blueprintable, ClassGroup=FSM, meta=(BlueprintSpawnableComponent))
class BASIC_BLOCKED_GAME_API UState : public UObject
{
	GENERATED_BODY()

public:
	UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
	void Enter();
	
	UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
	void Update();
	
	UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
	void Exit();
};

and then created a blueprint from it like this:

then I created this class:

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "State.h"
#include "Components/ActorComponent.h"
#include "StateMachine.generated.h"


UCLASS( ClassGroup=(FSM), meta=(BlueprintSpawnableComponent) )
class BASIC_BLOCKED_GAME_API UStateMachine : public UActorComponent
{
	GENERATED_BODY()

public:	
	// Sets default values for this component's properties
	UStateMachine();

private:
	UPROPERTY(EditAnywhere)
    UState* CurrentState;

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

public:	
	// Called every frame
	virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;

	void Initialize(UState* InitialState);

    void ChangeState(UState* NewState);
};

and added it as a component to an actor like this:

and in it, I can see the variables as you can see here:

but when I open the dropdown I can’t find the blueprint I created beforehand as you can see here:

Why does this happen what am I doing wrong or do not understand right?

CurrentState is an object- you’re trying to set a reference to an object that hasn’t yet been created.

You need to set that at runtime.

how can i do it?

or is there any other way i should try to implement such FSM idea?

You can just create it at runtime. Use the construct object node and then set your variable using the created object.

You may want to do this in the construction script / constructor, but it just needs to be created before you try to reference it.