How would I go about creating a yardstick behaviour?
Like, if I have a stick divided into three sections, meaning it has four “control points”; one at each end of the stick and one at 1/3 of the length of the stick and another at 2/3 of the length of the stick.
I should be able to rotate around each of these points and the rest of the stick should rotate accordingly, like a parent-child setup. I also want the points to rotate when we “stretch out” the stick.
For example:
Stick is completely straight, going from left to right with the first control point at the left end. I rotate 45 degrees around the second control point. If I now grab the third control point and pull straight to the right the stick is supposed to straighten out again, until it is as straight as possible, at which point I cannot pull any more.
I hope my textual description is visual enough to make it clear what kind of behaviour I’m trying to achieve. I pretty much want it to work exactly like a yardstick with “anchor points” at the ends of stick.
That works fine for rotating, but doesn’t work at all when it comes to moving any of the child objects. The parents will be left behind, not to mention “stretch out” accordingly.
I’ve tried playing around with joints a bit, but without any luck.
You talk about pulling/stretch the points.
So if you grabbed the last child in the chain and moved it, the yardstick would straighten out?
If so, that would require some sort of IK (Inverse Kinematic) solver. I’d play around with HingeJoint, but I’ve only done IK in Havok, so not sure about PhysX.
Exactly. And if the yardstick is fully straight, it wouldn’t be able to be move anymore in that direction. The user would still be able to rotate it all by moving that last child and moving it in a circular motion (once the yardstick is fully stretched).
I’ll look it up and see if I can manage to understand how that works. It’s all new to me, but it feels as though using some kind of physics system for this should be the right way to go.