(Yesterday, 02:22 PM)Jawsarn Wrote: I wish we could have a script on an actor that references and links it to a solver (limiting it to world space if required). Thus making it easy not having the hierarchy dependent on what framework used for displaying visuals.
Hi!
This is how Obi 1.0 worked, we quickly left this design behind as it's a never-ending source of trouble.
By allowing actors to reference any solver in the scene, actor transforms cannot be assumed to be
under the solver in the hierarchy (the solver might actually be a sibling of the actor, or even a child) so this requires multiple code paths that transform all simulation data differently depending on each specific case.
Inertial forces don't work in the
sibling or
child solver cases because the solver may move independently from the actor, and in these cases applying inertia doesn't make sense. This makes it fairly easy to inadvertently set things up incorrectly (for instance, by mixing actors that are children and parents of the solver in the same simulation. Or, by adding an actor to a solver, reparenting the actor somewhere else and forgetting to call the appropriate code to signal the change) and is a constant source of user error.
We had error messages/info globes all over the place to try and steer users away from incorrect use cases, but it was clunky to say the least. To get rid of all these issues, we took note of how Unity solves the same problem in many of its systems: Canvases are required to be parents of UI elements, Animators are required to be parents of the bone hierarchy, IK Managers must be parents of IK targets, etc.
In our case, forcing the solver to be up the actor's hierarchy (at any nesting level, doesn't have to be an immediate parent) got rid of the 3 different code paths, got rid of all the edge case transforms, allowed inertial forces to always work properly, and made it impossible to set things up incorrectly: an actor is either managed by a solver or it isn't. Reparenting the actor automatically swaps solvers both in-editor and in scripts, so API complexity is also greatly reduced.
I know the "let me specify an arbitrary solver transform for each actor" desire is strong, but we've been there before and it's certainly not a good place.
kind regards,