We are using Unreal Engine 5.7.1 and encountered two issues related to StateTree:
1. When using StateTree property binding, we found that it is not possible to bind to an element inside an array.
- We cannot bind a specific array element to another property.
- We also cannot bind another property to a specific array element.
Is this a known limitation or a bug?
2. When using an array of structs in a StateTree, modifying a single element causes a crash that is 100% reproducible.
The crash occurs in
UE::StateTree::PropertyHelpers::DispatchPostEditToNodes
at the check:
```
check(CurrentPropNode->GetNextNode() == nullptr);
```
We noticed that the crash is caused by using the array property name instead of the inner property name when retrieving the changed index.
Specifically, changing the line
```
const int32 Index = InPropertyChangedEvent.GetArrayIndex(ArrayProperty->GetName());
```
to
```
const int32 Index = InPropertyChangedEvent.GetArrayIndex(ArrayProperty->Inner->GetName());
```
fixes the crash in our project, and we have not seen any issues after applying this adjustment.
Is this crash a known bug?
And is the above modification a correct fix, or could it cause side effects elsewhere?
[Attachment Removed]
Hi xinghun liu,
Thank you for the report. I’ve been trying to reproduce the issues you described, but unfortunately I was unsuccessful so far. In my tests using UE 5.7.1, I seem to be able to make property bindings to/from individual array elements without any problems. Additionally, I could not observe a crash when making changes to members of structs contained inside arrays.
Do the issues repro on a vanilla UE 5.7.1 installation from the Epic Games Launcher? Also, would it be possible for you to provide some reproduction steps, starting with a blank project, that lead to the behavior and crash you observed? Alternatively, if you have the time to prepare and are able to share a small repro project that demonstrates the issues, that would be most valuable for us to track down the problem.
About your proposed change, on a first look the original line seems correct:
const int32 Index = InPropertyChangedEvent.GetArrayIndex(ArrayProperty->GetName());The PropertyChangedEvent contains a list of property nodes representing multiple levels of a nested property hiearachy. When one of these nodes is an array, the line above should return the index that was changed/added/removed. This should be an invalid index only when removing the last entry of the array, in which case “check(CurrentPropNode->GetNextNode() == nullptr)” should succeed.
I am still investigating this, but if you can provide repro steps or a repro project, it could be very helpful.
Best regards,
Vitor
[Attachment Removed]
OK, Thanks. We have found the cause of the problem.
We are using AngelScript as the scripting solution in our project, and we’ve encountered an issue related to array types defined in C++ vs. AngelScript.
If an array type is declared in C++, everything works correctly:
• It can be bound to a property
• The property can also bind back to this array
• Its elements can be bound to other elements or to elements of other arrays
However, if the array type is declared in AngelScript, or if we declare a C++ type but declare an array of that type in AngelScript, we encounter several problems:
The editor crashes when modifying the array
Elements inside the array cannot be bound to other elements
Elements cannot be bound to elements of other arrays
The array property itself cannot be properly connected in the binding system
It seems that arrays originating from AngelScript (either declared directly in AS or AS-created arrays of C++ types) are not fully compatible with UE’s property reflection or binding/broadcasting system.
[Attachment Removed]
Hi xinghun liu,
I’m glad you found the cause of the problem. Unfortunately we cannot offer support for third-party modifications and plugins. One additional piece of information that might be helpful for you is that the FPropertyChangedEvent structure seems to have gone through some changes from UE 5.5 to UE 5.6, so maybe AngelScript was not fully updated to account for that yet. I noticed that, up to UE 5.5, the property name of an Array’s inner type was “<ArrayPropName>_InnerType” when the array was a property defined in the editor (not in C++). Starting with UE 5.6, that property name seems to have dropped the “_InnerType” suffix. This might be helpful for the developers of Unreal AngelScript.
Best regards,
Vitor
[Attachment Removed]
Hi xinghun liu,
While investigating this issue, I found a related issue that is probably part of the problem. The issue happens whenever a property contains two nested arrays with the exact same name (for example, a property “MyArray” which is an array of structs “MyStruct”, where that struct also contains an array named “MyArray”). Please verify if you have more than one array with the same name anywhere on the hierarchy of your affected properties, and if so try to change those names to see if the problem goes away.
I have filed an internal bug report regarding this, here’s the tracking number: UE-358725. The link should become available once the engine devs mark it as public.
Let me know if this helps!
Best regards,
Vitor
[Attachment Removed]