I want to put the camera on a "boom arm" consisting of an anchor point, a massive fulcrum object in the middle, and a light camera mount point on the end. The idea is that when the player jumps up, I want the camera to swing around the fulcrum so it's below the player and looking up, and then when the player falls I want the camera to swing back up while the player's side of the lever is pushed down in relation to the relatively stationary fulcrum. On the other hand if the player moves a substantial distance he should drag the fulcrum along with him.
The thing is, I want the camera to behave as if it is attached to the player, but I don't want the player's physics in turn affected by the camera arm. So I can't just connect the fulcrum directly to the player object, that's why I'm using an anchor object instead of connecting directly to the player. I'm using slider constraints with a fixed linear length to connect them. I turned collisions off on the anchor object and I'm using a special motion state to lock the anchor object's position to the player object, like this:
Code: Select all
void LockAnimator::setWorldTransform(btTransform const& worldTrans)
{
// Ignore set, always use the target's transform without change
}
void LockAnimator::getWorldTransform(btTransform& worldTrans) const
{
// forward the target's position as our position.
target.getWorldTransform(worldTrans);
}
Unfortunately, the system of three bodies behaves really strangely when I do this, rotating and shaking rapidly until it all flies apart. It doesn't do that if I use a regular motion state on the anchor, so I'm thinking that the lack of feedback makes constraints not work right? I also have the problem that, when I'm not locking the anchor point, the system flies together, bounces apart, and then spins like a top, as if the arms were on a stretched spring that has been released, even though I'm taking care to ensure the starting distance between the points is exactly equal to the fixed linear distance of the slider constraint. What's up with that? I can make the spinning worse by deliberately making a discrepancy there, but I can't seem to eliminate the spin by minimizing the difference.
Is this the best way to accomplish what I'm trying to do?