StateTree not working

Hi,

I have added StateTree as Property in C++ code:

UCLASS(Abstract)
class ULTIMATIVESWAFFENSYSTEM_API AUWSAICharacter : public AALSCharacter, public IUWSInteractOnHitInterface {

GENERATED_BODY()

public:

AUWSAICharacter(const FObjectInitializer& ObjectInitializer);


// StateTree component instance
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UWS | AI", Meta = (AllowPrivateAccess = "true"))
UStateTreeComponent* StateTree;

};

AUWSAICharacter::AUWSAICharacter(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
PrimaryActorTick.bCanEverTick = true;
// Create the StateTree component
StateTree = CreateDefaultSubobject(TEXT(“StateTreeComponent”));

}

But when I want to StopLogic im Blueprings or access it in AI Controller Blueprint it does not working and in Message Log such error:

Blueprint Runtime Error: “Accessed None trying to read (real) property StateTree in UWSAICharacter”. Node: Stop Logic Graph: EventGraph Function: Execute Ubergraph UWS AIBase Character Blueprint: UWS_AIBaseCharacter

What I need to do that I can stoplogic of state tree using blueprints?

Ruslan

Looks like you forgot the template argument. Try this:
StateTree = CreateDefaultSubobject<UStateTreeComponent>(TEXT("StateTreeComponent"));

To add to @Countsie answer:

.h

UCLASS(Abstract)
class ULTIMATIVESWAFFENSYSTEM_API AUWSAICharacter : public AALSCharacter, public IUWSInteractOnHitInterface 
{
    GENERATED_BODY()

public:

    AUWSAICharacter(const FObjectInitializer& ObjectInitializer);


    // StateTree component instance
    UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "UWS | AI", Meta = (AllowPrivateAccess = "true"))
    TObjectPtr<UStateTreeComponent> StateTree; // Use TObjectPtr<> instead of *
};

.cpp

AUWSAICharacter::AUWSAICharacter(const FObjectInitializer& ObjectInitializer)
    : Super(ObjectInitializer)
{
    PrimaryActorTick.bCanEverTick = true;
    // Create the StateTree component
    StateTree = CreateDefaultSubobject<UStateTreeComponent>(TEXT("StateTreeComponent"));
}

.Build.cs

PublicDependencyModuleNames.AddRange(new[]
{
    ...,
    "AIModule",
    "GameplayTags",
    "GameplayStateTreeModule",
    "StateTreeModule",
});

TObjectPtr<>
https://dev.epicgames.com/documentation/unreal-engine/object-pointers-in-unreal-engine