PhysX Thrid Person Camera

Hello,

I’m doing a sort of solar system simulation. I have a small planet that I want to follow by my camera. The planet is orbiting around the sun with physics and custom applied gravity. So it’s made of a RigidDynamicActor.

I’d would like my camera to follow the planet smoothly and with the feel that it’s connected to the planet by a spring, so that when the planet’s velocity changes, then the camera’s velocity is adjusted with a slight delay.

I’ve tried to connect them both with various joints, but I have failed in all cases. For example, I really don’t want the camera Actor to physically affect the planet its attached to, and all typed of joints fails on this matter.

Any guidelines of how I should compose my camera system. Should I make the camera Kinematic instead?

Hi,

are you really really really sure to use a PxActor for your camera?
I guess you need no collision for your camera system, so there is no need for (expensive)
calculation of physic for “smoothing / damping” of the camera.

You could use a deltaTime value for moving your camera, depending on the framerate, which is always 1/60 or something else behind the actual position of the camera.

I dont know how I could explain it better, here is the way I did it:

mPivotNode->setPosition(mBodyNode->getPosition() + Vector3::UNIT_Y * 10);
mGoalPosition = mGoalNode->_getDerivedPosition() - mCameraNode->_getDerivedPosition();
if (mGoalPosition.x < 0.1f && mGoalPosition.x > -0.1f) mGoalPosition.x = 0.f;
if (mGoalPosition.y < 0.1f && mGoalPosition.y > -0.1f) mGoalPosition.y = 0.f;
if (mGoalPosition.z < 0.1f && mGoalPosition.z > -0.1f) mGoalPosition.z = 0.f;

float delta = mDeltaTime * mStiffness;
if (delta >= 1.f) delta = 1.f; // Just tune it, it fixes extreme movement

if (mGoalPosition != Vector3::ZERO) mCameraNode->translate(mGoalPosition*delta);
mCameraNode->lookAt(mPivotNode->_getDerivedPosition(), Node::TS_WORLD);

Maybe you get the point.