From a14599bb15df7a8d36399b24b77a577e92aab384 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 14 Apr 2026 16:02:31 +0200 Subject: [PATCH] Add `Per Instance Random` node to Anim Graph --- Source/Editor/Surface/Archetypes/Animation.cs | 12 ++++++++++++ .../Engine/Animations/Graph/AnimGroup.Animation.cpp | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/Source/Editor/Surface/Archetypes/Animation.cs b/Source/Editor/Surface/Archetypes/Animation.cs index b29d027f8..e376c3e43 100644 --- a/Source/Editor/Surface/Archetypes/Animation.cs +++ b/Source/Editor/Surface/Archetypes/Animation.cs @@ -1126,6 +1126,18 @@ namespace FlaxEditor.Surface.Archetypes NodeElementArchetype.Factory.Text(0, Surface.Constants.LayoutOffsetY * 8, "Nodes:", tooltip:"Amount of nodes in a chain to simulate, starting from the End Node going up in the hierarchy. Excluding root node the chain is attached to."), } }, + new NodeArchetype + { + TypeID = 36, + Title = "Per Instance Random", + Description = "Per object instance random value (normalized to range 0-1)", + Flags = NodeFlags.AnimGraph, + Size = new Float2(200, 30), + Elements = new[] + { + NodeElementArchetype.Factory.Output(0, "", typeof(float), 0), + } + }, }; } } diff --git a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp index 71f922792..e06f0deaa 100644 --- a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp +++ b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp @@ -2653,6 +2653,13 @@ void AnimGraphExecutor::ProcessGroupAnimation(Box* boxBase, Node* nodeBase, Valu value = nodes; break; } + // Per Instance Random + case 36: + { + auto* actor = ScriptingObject::Cast(context.Data->Object); + value = actor ? actor->GetPerInstanceRandom() : 0.0f; + break; + } default: break; }