Archived

This topic is now archived and is closed to further replies.

browny

wobbling motion of camera as in FPS games

Recommended Posts

browny    139
what is the basic principle of creating a sort of wobbling motion of camera while moving forward in FPS games. I mean , the camera should be wobbling sidewise a little as well as bump up and down and all these should take place around the forward velocity vector..... any good mathematical model ?

Share this post


Link to post
Share on other sites
oliii    2196
in many games, it''s just a sinewave. bobbing sideway is too much too take .as far as the mathematical model, a sinewave with increasing amplitude and frequency with speed.

Share this post


Link to post
Share on other sites
Chacha    138
I''m also wanting to implement this particular FPS camera motion, and I''ve been studying the movement of FPS games, and it seems to me that when you''re standing still, the camera bobs up and down, but NOT side to side. But when you''re moving, it looks like you''re swaying from side to side aswell as bobbing up and down. Is this correct?

And oliii, how would you go about implementing a sinewave? I''m guessing that you would need to perform the sinewave calculations on the up vector of your camera (for bobbing up and down), right? Have you got any more information/tutorials on implementing this?

Share this post


Link to post
Share on other sites
oliii    2196
It''s trivial really. you store an angle value and amplitude value, and add a component Up * sin(angle) * amplitude;

something like


// calculate camera orientation from player yaw and pitch angles

CalculateCameraOrientation();

// calculate camera position from player position and posture

// postures are prone / crouch / stand

CalculateCameraPosition();

void AddBobEffect()
{
// values based on posture for different effects

// depending if you are prone, crouch or stand up

float angle_vel_coeff[] = { 0.02f, 0.03f, 0.05f };
float amplitude_coeff[] = { 0.3f, 0.4f, 1.0f };

angle_vel = player_speed * angle_vel_coeff[player_posture];
amplitude = player_speed * amplitude_coeff[player_posture];

angle += fmod(angle_vel * dt)

if (angle > Pi * 2.0f)
angle -= Pi * 2.0f;
else if (angle < -Pi * 2.0f)
angle += Pi * 2.0f;

Camera.Position += Camera.Up * amplitude * sin(angle);
// equivalent to : Camera.Position.y += amplitude * sin(angle);


}


coeffs are completely random. you need to tweak the values to a range you like. Also, it''s good to clamp amplitude / angle_vel to a decent range to avoid over-the-top effect.

for the swaying, you can do a similar thing. Make sure the angle_vel coefficients are different (even by a small value), to avoid having a weird circular effect. Make the two movements out of phase, basically.

Share this post


Link to post
Share on other sites
Zorodius    259
I''ve never quite understood why some people like this feature. Your brain compensates for most of the bobbing when you''re walking around in real life anyway. I''m not the only one who finds it nauseating - your players might as well, so you should make it an optional feature.

"Baby-killer is a bad word though. Notice how as soon as you say it, you think negative things." - Peon

Share this post


Link to post
Share on other sites
Dmytry    1151
Yes,i agree with that this moving camera is not a very good idea,just do simple test. Just compare results of moving your head and looking on something,or look at something moving.
i think, "biology for games" are needed as well as physics.

Share this post


Link to post
Share on other sites
oliii    2196
the best would be to have in the animation, a flag for a given keyframe, like saying "footsteps", then you can do a small camera perturbation when the keyframe is triggered. Even footsteps_right, footsteps_left, and stuff like that... But I agree, I''m not a big fan of the camera bobbing, but it''s got to be there, coz some people like it. It''s like lens flares (hehehe...).

Share this post


Link to post
Share on other sites