Chase Cam

Hi all,

I was wondering on a way of making a chase camera. I have searched the internet for an article, yet no luck. Can anyone please point me in the right direction.

Thx a million

a really nice site to look at, the spring model model might be with a great help for you :).

so what your saying is set a virtual spring between the camera and the target, and let the spring do the rest?

exactly, letting the spring do the camera motion will make your camera movment independent of anything else, say your game frame rate, and also cool effect for chasing, fast first, slowly closing to the target (forget what does it mean in english :frowning: ).

thx OutRunner. The Spring Model for camera motion is in my game. :slight_smile:

if anyone is interested, here’s my code:

public class SpringMotion {
    // pa = target
    // pb = currentPos
    // k = spring constant
    // deltaDistance = how long is the spring
    public static Vector3f computeSpringForce(Vector3f pa, Vector3f pb, float k, float deltaDistance) {
        Vector3f force_dir = new Vector3f();
        Vector3f force = new Vector3f();
        float intensity, distance, delta;
        // get the distance
        float dx = pb.x - pa.x;
        float dy = pb.y - pa.y;
        float dz = pb.z - pa.z;
        distance = (float)Math.sqrt((dx*dx)+(dy*dy)+(dz*dz));
        if (distance < 0.0000005f) {
            force.x = force.y = force.z = 0.0f;
            return force;
        force_dir.x = dx;
        force_dir.y = dy;
        force_dir.z = dz;
        // normalise
        force_dir.x /= distance;
        force_dir.y /= distance;
        force_dir.z /= distance;
        delta = distance - deltaDistance;
        intensity = k*delta;
        force.x = intensity * force_dir.x;
        force.y = intensity * force_dir.y;
        force.z = intensity * force_dir.z;
        return force;


and in the update method, all you have to do is this:

        Vector3f rForce = SpringMotion.computeSpringForce(box1.getLocalTranslation(),
                camNode.getLocalTranslation(), 2f, 10f);

        camNode.getLocalTranslation().x -= rForce.x * interpolation;
        camNode.getLocalTranslation().y -= rForce.y * interpolation;
        camNode.getLocalTranslation().z -= rForce.z * interpolation;

hope that helps

This might also help. :o

thats wayyyy to advanced for me. Il stick with my spring thank you very much. Hehe :smiley:

righteo, here’s the little app I made for the cam:

Is that Ok as a chase cam? Id like to get the player’s point of view. :slight_smile:

Played with it for a moment, and it seemed pretty good. Hard to tell how it will do as a chase cam since I couldn’t figure out how to move the ship to make it chase it. But the spring worked well.

You might also want to implement a “lock on” so the camera is always looking at the player’s character. The rotation to point at the character can also be a spring.

Hey DP, looking good. What game will you use the chase cam for?

You might consider using a spherical coordinate system in your chase camera. It’s what I’m using in the demo I sent you last week.

yeah, you cant move the player yet. Renanse, I would be very interested in the spherical co-ordinate system of yours, any articles/sites I can find out more?

Btw, its for VolatileZapper 2

Game programming gems #4 has some good stuff. I had to add several tweaks to his code for it to work properly though.

right, download new zip, now ship moves and cam follows. And can someone plz plz plz plz rotate that ship in milkshape for me! :smiley:


right, lock on complete. Is that acceptable as a chase cam?

sorry to bring this thread back from the dead ( i have been doing that quite recently lately ). Would you mind looking at this demo and telling me how you find the camera?

I’am new to all this 3d stuff, so sorry for this stupid question.

I have an 3d object (a spaceship), which should be always viewed from behind. So I set the camera location to my3dobject->getLocalTransformation() and the camera rotation to my3dobject->getLocalRotation(). This works for the center but If I move my translation coordinates a little bit in -z direction(which I must, otherwise I’am in the middle of my object), the rotation fails. Is there any way, to rotate the camera around the the center and then translate it, not the other way around?