(9 hours ago)sacb0y Wrote: Okay I see, so my testing is wrong, I'll try in a bit more of a gameplay scenario.
It's not just the testing that's wrong, this is more of a basic misconception: transforms are simply positions/orientations in space, no physics involved in them (no second order effects, no velocity, inertia, or anything like that) so anything that drives transform data directly (like animation) won't work with physics at all. It's one of the reasons why you often see character limbs clip trough walls in games.
This applies
no matter which physics engine you're using or in what context the transform manipulation takes place (using gizmos in the scene view, using custom scripts, using animation, etc). For physics consistency you need to drive rigidbody
velocity, either by applying forces, accelerations, or impulses.
(9 hours ago)sacb0y Wrote: So if this is on a character as long as the character is moved by physics and animation it should work?
I'm assuming by animation you mean skeletal animation, as in the typical humanoid character setup: a capsule for collision detection and a skinned mesh renderer for skeletal animation. In that case, it won't work: as mentioned before, manipulating transform values directly has zero regards for physics (which is what animation does: it simply sets joint position/orientation every frame). Unless your character is
100% physics based (eg. active ragdoll) then you can't use physics for this.
(9 hours ago)sacb0y Wrote: What is the recommended setup for an animated character if this is the case?
There's no single approach for characters. It very much depends on how your character needs to work and how you've decided it should interact with user input, the world around it, etc. For instance, if your character controller is fully kinematic then you'd bypass physics entirely and do this kinematically as well. If your character controller is physics based but you're using skeletal animation to drive its joints, then you'd use linear blend skinning to dynamically "skin" points (be it rope particles, spline control points or whatever your strings are made of) to the joint hierarchy. Only in case both your character controller and your joint hierarchy are fully physics driven you can use physics for this.
Note this is not the typical use case you'd face with characters, which is a rope-like object statically attached to an animated character (eg a belt, a braid, a tail, etc). There, points in the rope are kinematically attached to the character and they
start and
stay attached to it. That case is a lot simpler and Obi has its own dedicated component for it:
ObiParticleAttachment.
Yours is a *very* advanced use case and requires deep understanding of how physics works, how animation works, how character controllers work (both kinematic and physics-based, as they have different tradeoffs) and how they all fit together in various scenarios.
(9 hours ago)sacb0y Wrote: I'm fine if it's not perfect. But are there any code examples to the parenting? I tried something like this with splines but it was rather slow.
For this to be performant you
must use multithreading. Iterating trough a bazillion particles every frame in the main thread using C# is bound to be slow no matter the kind of primitive (spline control points, rope particles, transforms, rigidbodies) you use.
The manual contains explanation and sample snippets for
collision callbacks as well as
particle manipulation, most using single-threaded code for clarity.
let me know if you need further help,
kind regards