GeorgeS2019 / Godot4-3D-IK-Demo

0 stars 0 forks source link

MotionMatchingDiscussionJul2023 #11

Open GeorgeS2019 opened 1 year ago

GeorgeS2019 commented 1 year ago
================================================== [Daniel Holden ](https://theorangeduck.com/) motion matching is being[ implemented](https://github.com/orangeduck/Motion-Matching) in [Unity3D](https://github.com/JLPM22/MotionMatching) and I think it may be prudent for us to with another perspective from another Game Engine e.g. Unity3D and then re-examine **how best** to do that in Godot. The Original [2019 Godot Motion Matching UI](https://godotengine.org/article/gsoc-2019-progress-report-1-part-2/#motion-matching) was designed and implemented by Juan Linietsky @reduz The key question is scalability of @Remi123 Godot4 Motion Matching solution by being flexible in incorporating new Motion by e.g. importing new BVH files. # Pre-processing to store ## Pose => Motion Data ## Features => Motion Features ![image](https://github.com/Remi123/MotionMatching/assets/49812372/abfa0af8-b233-4f91-9403-bb19bc2e32b2) ![image](https://github.com/Remi123/MotionMatching/assets/49812372/ce50d593-dacf-4351-8037-f4f2374c1ef6)

@CBerry22

On behalf of many of us who care about the Godot community, I wonder if you could apply your experience with physics-based active ragdoll to motion matching

There are similarities between them

To learn about Motion Matching

(provided by Readme)

Introduction video O3DE implementation blog Daniel Holden aka OrangeDuck's blog Spring algorithm and controller Motion Matching implementation Fitting Motion with Animation

Discussion and elaboration provided by @Remi123

This project has scalability as one of its core foundation. Since many users will try to use it with very different quality of animation, from professional post-processed motion-captured animations to Mixamo animations to their own animations of varying quality, the system must be robust, easy to debug and easy to fix.

Nomenclature:

Some comments about my project and some possibilities it allows.

  1. Animation Re-targeting make importing BVH, FBX and GLTF animation a non-issues for this project. My own project use a mix of motion captured and mixamo animations without trouble.
  2. Debugging is important. Each features is able to show on gizmo ( only in the editor for the moment) showing lines or meshes to show velocity, bone position, etc.
  3. The Kdtree implementation that we choose has three distinct advantages over using other methods : Weight, void* Data and a Predicate,
    • Weight allows to specify the importance of different features over others. The trajectory is usually the most important in locomotion.
    • Void* data allows me to reference some data at each node. I use it to store a bitfield representing the category ( Walk, run, etc)
    • Predicate allows to filter results. I use it for the categories, but I also have ideas in the editor.

What this project aims is to provide multiple type of features, ones more adapted for typical locomotion that are continuously updated, others would be better for Melee Combat similar to For Honor, or other better used for Parkour. Each would be hosted by it's own kdtree and the user can select which one are active by code. This is what we define as scalability in this project.

This project is still a WIP and as such some features were implemented as a prototype for now.

Additional background

Implement Motion Matching

Other FYI

Retool AnimationTree parameter system to use a blackboard-based approach

================================================== @maximkulkin With respect to your feedback on e.g. [**AnimationBlendTree node with parameters**](https://github.com/godotengine/godot-proposals/issues/3352#issuecomment-1510282834), I think this project needs to address this possibility too. value your input if you have time. @SaracenOne [Retool AnimationTree parameter system to use a blackboard-based approach](https://github.com/godotengine/godot-proposals/issues/3352) In this project, we are also facing how to deal with **AinmationTree parameter system** to a blackboard that returns a motion-matched query. Value your feedback

@GeorgeS2019 @CBerry22 @maximkulkin @SaracenOne

I can share my inputs on each subject.

AnimationTree My plugin is outside AnimationTree for now, it's only a node that find the best poses and output the name and timestamp of the animation that best match it. For example, "WalkForward" at time 0.4. This is all my plugin output, but I do it every 0.2 seconds.

Once this is known I need to blend to the desired pose. I have a simple setup in the animationtree that blend between two poses, but basically all I need is a node that blend between the current pose, and the poses at my desired animation timestamp.

I value the fact that my setup is technically just a slightly more complex AnimationNode, as the user can use all the things that AnimationTree is able to output.

Inertialization vs active ragdoll. I remembered that he had a Youtube channel, and looked back at the active ragdoll at this link. Quite frankly I'm impressed and I think it's possible to implement the blending using active ragdoll, but I have some reservation.

Issues 1 First of all, he is using two skeletons, one physical using PhysicalBone3D and the other that is playing the animation. The physical skeleton is trying to match the position of the equivalent bone in the normal rig using some spring calculation. It is indeed very similar to inertialization which is also derived from springs, although the calculation isn't the same but for this discussion it's similar enough.

With my plugin, the animated rig would simply go to the desired poses, wait 0.X seconds that is configurable, and continue playing the rest of the animation and the physical bones would simply catch up with the rest of the animation.

I'll try to make it so that there is only one skeleton, but I have to test it if is possible.

Issues 2 For my purpose, it is still a workaround a proper node that blend realistically between poses very often. My setup that switch between the current and desired poses would just be replaced by an active ragdoll setup that still needs maintenance, but now with double the skeletons.

Inertialization I've discussed with Tokage about a solution to the inertialization. In essence, the real problem that I have to workaround is that I cannot create an AnimationNode that manipulate the Skeleton3D directly. The animationtree has it's own structure to represent a blend of all the nodes and I want to keep it that way.

My current solution would be to have a node similar to an AnimationNode, and once it receive the signal to switch to a desired pose, create a temporary animation with the current bones positions and rotations. I then smoothly transitions to the desired pose by manipulating the animations tracks's key values instead of the skeleton bones positions. The animationTree only see an Animation and I'm free to manipulate the values however I see fit. Once the transition is done I simply remove the temporary animation and play the desired one.