StateTree binding doesn't honor normal access rules

This is a bit of a weird one, but StateTrees don’t appear to honor the same rules that access to variables usually have, which makes it very awkward to work with.

For example, if you have an AI controller and you wanted to bind with an actor in it.

If the variable is public, you can bind to it:

public:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
AActor* TargetActor;

But if it’s protected, it’s not bindable, even though you’d expect it to be given it would be accessible in blueprints:

protected:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly)
AActor* TargetActor;

You also can’t bind to functions, so the following also will not work:

public:
UFUNCTION(BlueprintCallable)
AActor* GetTargetActor();

I’m specifically talking about binding as shown below. In the cases where it doesn’t work, TargetActor just is not there.

It happens in 5.5 as well as ue5-main currently.

Overall this means binding is super awkward as it means everything has to be a plain public variable, which obviously isn’t good for encapsulation.

Anyone have any idea what is going on here, it seems odd that the behavior is different for a StateTree vs literally anything else?

After some more investigation, it works as expected in Unreal 5.4, but is broken in 5.5 and mainline.

As such, I believe this is a bug/regression unfortunately, unless it was changed intentionally for some reason.

Wondering if you have any insight on this @James.Keeling ?

You can work around this with AllowPrivateAcccess:

UPROPERTY(VisibleAnywhere, BlueprintReadOnly, meta=(AllowPrivateAccess=true))

Usually that’s only used for private variables afaik, but in this case it causes protected ones to show up in the StateTree editor as well. The behavior is still inconsistent with 5.4 and other blueprint variable access, so something changed, but it’s an easy enough workaround at least.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.