Spring/Mass Cameras, Skyboxes

The Spring/Mass Camera is an awesome example of math in action.

If you rigidly fix the camera to the character, it feels like the world moves and he stands still (or gives the feeling like those helmet cams in the Worlds Fartiest Race).

A Spring/Mass Camera lets you get out a little before the camera starts following.  Take note of it next time you play a 3rd person game.

I like to implement it as two spring/masses one for where the camera is, and one for what the camera is looking at.

Check out the video:

http://www.youtube.com/watch?v=7CswJKqefM4

Look at this awesometown math:

float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

#region MATH_ALERT

//well, physic, whatever.

// Calculate spring force

Vector3 stretch = ActualPosition – DesiredPosition;

Vector3 force = -Stiffness * stretch – Damping * Velocity;

// Apply acceleration

Vector3 acceleration = force / Mass;

Velocity = Velocity + (acceleration * elapsed);

// Apply velocity

ActualPosition = ActualPosition + (Velocity * elapsed);

#endregion

Also, I got skyboxes, turning characters and multiple characters going

Leave a Reply