# StateTree not working 

**URL:** <https://forums.unrealengine.com/t/statetree-not-working/2746362>\
**Category:** C++\
**Tags:** unreal-engine, question\
**Created:** [August 25, 2026, 3:13pm UTC](https://forums.unrealengine.com/t/statetree-not-working/2746362 "2026-08-25T15:13:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ruslanmin2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ruslanmin2](https://forums.unrealengine.com/u/Ruslanmin2)\
**Post date:** [August 25, 2026, 3:13pm UTC](https://forums.unrealengine.com/t/statetree-not-working/2746362/1 "2026-08-25T15:13:30Z")

</div>

Hi,

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

UCLASS(Abstract)  
class ULTIMATIVESWAFFENSYSTEM\_API AUWSAICharacter : public AALSCharacter, public IUWSInteractOnHitInterface {

```auto
GENERATED_BODY()

```

public:

```auto
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

---

<div class="post-metadata">

**Author:** ![Countsie](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/countsie/32/1194632_2.png) [@Countsie](https://forums.unrealengine.com/u/Countsie)\
**Post date:** [August 25, 2026, 8:01pm UTC](https://forums.unrealengine.com/t/statetree-not-working/2746362/2 "2026-08-25T20:01:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SolidSk](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/solidsk/32/1194513_2.png) [@SolidSk](https://forums.unrealengine.com/u/SolidSk)\
**Post date:** [August 25, 2026, 8:54pm UTC](https://forums.unrealengine.com/t/statetree-not-working/2746362/3 "2026-08-25T20:54:48Z")

</div>

To add to @Countsie answer:

.h

```auto
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

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

```

.Build.cs

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

```

TObjectPtr\<\>  
[https://dev.epicgames.com/documentation/unreal-engine/object-pointers-in-unreal-engine](https://dev.epicgames.com/documentation/unreal-engine/object-pointers-in-unreal-engine)

---

<div class="post-metadata">

**Author:** ![Ruslanmin2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ruslanmin2](https://forums.unrealengine.com/u/Ruslanmin2)\
**Post date:** [August 30, 2026, 2:54pm UTC](https://forums.unrealengine.com/t/statetree-not-working/2746362/4 "2026-08-30T14:54:06Z")

</div>

Thanks a lot! It works!
