diff --git a/Source/Editor/Windows/Assets/AnimationWindow.cs b/Source/Editor/Windows/Assets/AnimationWindow.cs index 8f88d93f6..c512d287f 100644 --- a/Source/Editor/Windows/Assets/AnimationWindow.cs +++ b/Source/Editor/Windows/Assets/AnimationWindow.cs @@ -48,7 +48,7 @@ namespace FlaxEditor.Windows.Assets // Use virtual animation graph to playback the animation _animGraph = FlaxEngine.Content.CreateVirtualAsset(); - _animGraph.InitAsAnimation(model, _window.Asset); + _animGraph.InitAsAnimation(model, _window.Asset, true, true); PreviewActor.AnimationGraph = _animGraph; } diff --git a/Source/Engine/Content/Assets/AnimationGraph.cpp b/Source/Engine/Content/Assets/AnimationGraph.cpp index fe87abfe4..9b431aefa 100644 --- a/Source/Engine/Content/Assets/AnimationGraph.cpp +++ b/Source/Engine/Content/Assets/AnimationGraph.cpp @@ -67,7 +67,7 @@ void AnimationGraph::OnDependencyModified(BinaryAsset* asset) #endif -bool AnimationGraph::InitAsAnimation(SkinnedModel* baseModel, Animation* anim, bool loop) +bool AnimationGraph::InitAsAnimation(SkinnedModel* baseModel, Animation* anim, bool loop, bool rootMotion) { if (!IsVirtual()) { @@ -89,7 +89,7 @@ bool AnimationGraph::InitAsAnimation(SkinnedModel* baseModel, Animation* anim, b rootNode.Type = GRAPH_NODE_MAKE_TYPE(9, 1); rootNode.ID = 1; rootNode.Values.Resize(1); - rootNode.Values[0] = (int32)RootMotionMode::NoExtraction; + rootNode.Values[0] = (int32)(rootMotion ? RootMotionExtraction::Enable : RootMotionExtraction::Ignore); rootNode.Boxes.Resize(1); rootNode.Boxes[0] = AnimGraphBox(&rootNode, 0, VariantType::Void); auto& animNode = graph.Nodes[1]; diff --git a/Source/Engine/Content/Assets/AnimationGraph.h b/Source/Engine/Content/Assets/AnimationGraph.h index f378b9bbe..716329347 100644 --- a/Source/Engine/Content/Assets/AnimationGraph.h +++ b/Source/Engine/Content/Assets/AnimationGraph.h @@ -37,8 +37,9 @@ public: /// The base model asset. /// The animation to play. /// True if play animation in a loop. + /// True if apply root motion. Otherwise it will be ignored. /// True if failed, otherwise false. - API_FUNCTION() bool InitAsAnimation(SkinnedModel* baseModel, Animation* anim, bool loop = true); + API_FUNCTION() bool InitAsAnimation(SkinnedModel* baseModel, Animation* anim, bool loop = true, bool rootMotion = false); /// /// Tries to load surface graph from the asset.