Hi, all! This is mostly general gamedev question. This was bothering me for years and I implemented it about 10 times but never liked the result completely, so I ask. I have 3D game where characters can interact with each other in background to display some life in world, also player can interact with NPCs, also some interactions are scripted. For all that I'd like to make a system which would allow me to set up all characters AnimationTrees so that they play the whole action. The example of such actions is shaking hands, holding hands and walking, hugging, talking/reacting to talking, attacking/defending, attacking/reacting to attack, pushing (one character pushes another one and other one moves or holds), etc.
What I see it as in game world: Step 1. All actors function independently and roam freely doing independent actions. Step 2. Some condition occurs or scripted action activates. Step 3. The characters are assigned to the system somehow each having its role. Step 4. The system plays, and characters are no longer acting independently but according to the system which has its own state machine/decision tree/etc. i.e. logic, which plays animations, does other actions and decides when characters go free. Step 5. Characters are free again.
The biggest problems occur at Step2 and 5 because transitioning might require disabling physics and individual AIs, character must be placed at starting points for animations, etc. Andditionally, some different ways for root motion handling are required for everything to be in sync. Also lots of other problems occur if implementing this directly. Have anybody implemented such a system in Godot and have some advice to do it in robust way with proper design? Any help will be appreciated!