Help wanted: wobbly head/"bobblehead" effect code?
Blitz3D Forums/Blitz3D Programming/Help wanted: wobbly head/"bobblehead" effect code?
| ||
You know those statues with the oversized heads that bob and wobble about when you move them? The ones that look like this:![]() Well, I'd like to reproduce this wobbly effect in real time, but I don't have a clue as to how to go about it. The head and the torso are seperate models. The head should be attached to the body and "wobble about" in real time when the user turns/moves/steers the model - and the movement of the head should relate to and be influenced by the movement of the body rather than just constantly nodding up and down; it needs to dynamically react the movement of the body. Hope this makes sense. Has anyone got a code snippet that does this or can help me figure this out, please? |
| ||
real easy answer, use a pivot on the head. Then try some SIN / COS work on the pitch angle. |
| ||
Hmm. It needs to be more dynamic than that. The movement of the head should be the result of and in response to the specific movement (or lack of) of the body, rather than an unreactive automated movement. |
| ||
I would rig it as one model and use the head bone to make the head wobble. Apply force to the head bone in the opposite direction of the forces applied to the model. For example, when the body is at rest and accelerates by x,z ( ignore y, obviously) apply -x,-z to the head, because the head is above the center of gravity and will move in the opposite direction. When the model decelerates ( accelerates by -x,-z ) then apply x,z to the head bone. It's important to only use forces ( acceleration )and not speed though. You don't want a constant force applied when it's moving. You want forces applied when it accelerates or decelerates. At least IMO. Some kind of simple verlet engine with joints should be able to handle the actual movement, given the forces I mention above, or you could code it yourself pretty easily, but I wouldn't like to give advice on that as it's been a long time since I rolled my own physics and I might make a mistake or two. |
| ||
The head needs to be a seperate object, because the model is intended to be customisable (you can switch out heads, arms and bodies). Your advice is useful and it points me in the right direction (thanks!), but - argh - as both a complete physics novice and a mathematics dunce this all sounds hellishly complicated. I should also add that the head should return to its default upright, normal position when the model comes to a stop, and there needs to be some constraints on the maximum range of wobble. I don't derive any personal satisfaction from coding, nor do I want to reinvent the wheel, so if there is a simple (and - importantly - free) physics system that can handle this then I'll happily use it. |