From c2ea844f0c244bbf6d2de135d4e0f42f2d52f702 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Mar 2026 03:33:25 +0000 Subject: [PATCH] Fix StateRootNodeIndex mapping: use (Count - 1 - index) for reverse ChildProperties order Co-authored-by: LoogLong <86428208+LoogLong@users.noreply.github.com> --- FModel/ViewModels/AnimGraphViewModel.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FModel/ViewModels/AnimGraphViewModel.cs b/FModel/ViewModels/AnimGraphViewModel.cs index 2040cc10..7228a49e 100644 --- a/FModel/ViewModels/AnimGraphViewModel.cs +++ b/FModel/ViewModels/AnimGraphViewModel.cs @@ -653,6 +653,8 @@ public class AnimGraphViewModel metadata.StateNames.Add(stateName); // Mark root node via StateRootNodeIndex + // UE stores node indices in reverse order relative to ChildProperties, + // so the actual index into animNodeProps is (Count - 1 - stateRootIndex). if (!stateStruct.TryGetValue(out int stateRootIndex, "StateRootNodeIndex") || stateRootIndex < 0 || stateRootIndex >= animNodeProps.Count) { @@ -660,7 +662,8 @@ public class AnimGraphViewModel continue; } - var rootPropName = animNodeProps[stateRootIndex].name; + var mappedIndex = animNodeProps.Count - 1 - stateRootIndex; + var rootPropName = animNodeProps[mappedIndex].name; metadata.StateRootPropNames.Add(rootPropName); if (nodeByName.TryGetValue(rootPropName, out var rootNode)) rootNode.AdditionalProperties["BelongsToStateMachine"] = machineName;