Hi there,
i have a character who should move accordingly to the bending of his backbone. The more he bends the more he move fast straight or backward, He should also rotate when he twist the backbone.
Backbone is actually a bone, i don’t know how to script this thing. Thank you.
how does this backbone bend? Is it from a user input? Why is speed based on the bending of the backbone, and not the bending of the backbone based on the speed?
As you bend it more, you should have some value to define how much it is bent… this is your speed scale right there. (If you let it get bent by physics and don’t directly do it yourself in code, then you’ll need some geometry to calculate the amount of bending… dot products will be what you need… but I don’t know enough about your bones to tell you exactly)
Now you scale your velocity/acceleration on user input (unless you have some other way to control the character).
Thank you lordofduct. The reason is because i am workin on a kinect based application. That means that my character move forward and backward (sidewalk, etc.) based on how much the user bend via kinect capture.
I’d like to have the user to control the upper side of the character using his own movement, but to move all the body around he have to bend his back.
I my understanding i must define a range of no movement, then smoothly increase velocity when he bend more and more. The script should also understand the direction where the backbone is bending.
Ok, so the input is the user bending his back.
The model on screen mimics this bending.
And the speed is based on this.
Well you need to get the measure of bending from the kinect user input. There is probably special points on the player’s body returned by kinect. You just need to get a vector that defines normal ‘idle’ standing, and then a vector that represents the current bending (vector from waist to head/shoulders maybe?). Then the angle between the idle vector to this vector is the amount of bend there is.
Angle between two vectors is the arccos of the dot product of both vectors divided by the magnitudes of both (make them unit vectors to avoid this divided part, cause x / 1*1 = x).
acos( (A dot B) / ||A||*||B|| )
Here’s another idea. What about a raycast from the tip of the bone to a square under the feet of the character. The more this raycast hit is far from the center of the plane the more it moves fast in that specific direction and with that specific angulation.
Maybe should be easier to visualize/debug. What about this?
the head bone?
possibly…
you’d have to keep in mind though that what you’re essentially doing is an even more complicated (and costly) projection of one vector on another. A dot product is just the projection of one vector on another, like a shadow of one vector on the other.
this is a visual representation of dot product, the measure bar is your result

(think of A as the person, and B as the ground)
You’re basically doing the same thing, pretending the point of the one vector is the top bone, and you’re ray casting down, then finding the distance from that point to the feet. It’s a long way around technique, and uses the far slower raycasting.
furthermore, this “shadow” does not grow at a linear rate. As the person starts to bend, the shadow grows quickly. But the growth of it slows down very quickly (at a rate of acos). This is why I showed you the formula for getting the angle between two vectors. Angles change linearly… you remove that non-linear rate of change from it.
I understand, thank you very much.
I have to try this.