Talk:Camera Bob: Difference between revisions
No edit summary |
No edit summary |
||
Line 18: | Line 18: | ||
Near the top of gamemovement.cpp define the convars: (these are the values I used, you can change them of course) | Near the top of gamemovement.cpp define the convars: (these are the values I used, you can change them of course) | ||
<source lang="cpp"> | |||
// Camera Bob | // Camera Bob | ||
ConVar cl_viewbob_enabled ( "cl_viewbob_enabled", "1", 0, "Oscillation Toggle", true, 0, true, 1 ); | ConVar cl_viewbob_enabled ( "cl_viewbob_enabled", "1", 0, "Oscillation Toggle", true, 0, true, 1 ); | ||
Line 24: | Line 25: | ||
ConVar cl_viewbob_scale_y ( "cl_viewbob_scale_y", "0.1", 0, "Magnitude of Oscillation"); | ConVar cl_viewbob_scale_y ( "cl_viewbob_scale_y", "0.1", 0, "Magnitude of Oscillation"); | ||
ConVar cl_viewbob_scale_z ( "cl_viewbob_scale_z", "0.1", 0, "Magnitude of Oscillation"); | ConVar cl_viewbob_scale_z ( "cl_viewbob_scale_z", "0.1", 0, "Magnitude of Oscillation"); | ||
</source> | |||
then in the WalkMove function: | then in the WalkMove function: | ||
<source lang="cpp"> | |||
//view bob code | //view bob code | ||
if ( cl_viewbob_enabled.GetInt() == 1 && !engine->IsPaused() ) | if ( cl_viewbob_enabled.GetInt() == 1 && !engine->IsPaused() ) | ||
Line 37: | Line 40: | ||
} | } | ||
//end view bob code | //end view bob code | ||
</source> | |||
this way you can go in-game and test the scale x, y, and z values using the console to determine exactly where you want it. | this way you can go in-game and test the scale x, y, and z values using the console to determine exactly where you want it. | ||
hope this helps somebody! --[[User:Vecima|vecima]] 22:42, 11 April 2010 (UTC) | hope this helps somebody! --[[User:Vecima|vecima]] 22:42, 11 April 2010 (UTC) |
Revision as of 15:44, 11 April 2010
Just wanted to add that you probably want to change the first line
if ( cl_viewbob_enabled.GetInt() == 1)
to
if ( cl_viewbob_enabled.GetInt() == 1 && !engine->IsPaused() )
That way, it won't bob when the game is paused, and it'll prevent a huge bob effect from gathering up from pausing for a long time.
Oh, and after testing this effect, I personally found that it looked better with a zoffset, it looks more natural and is less nauseating (for me at least).
--Wilsonc 20:12, 23 July 2009 (UTC)
customization
This is what I did to make the view bob more customizable:
Near the top of gamemovement.cpp define the convars: (these are the values I used, you can change them of course)
// Camera Bob
ConVar cl_viewbob_enabled ( "cl_viewbob_enabled", "1", 0, "Oscillation Toggle", true, 0, true, 1 );
ConVar cl_viewbob_timer ( "cl_viewbob_timer", "6", 0, "Speed of Oscillation");
ConVar cl_viewbob_scale_x ( "cl_viewbob_scale_x", "0.0", 0, "Magnitude of Oscillation");
ConVar cl_viewbob_scale_y ( "cl_viewbob_scale_y", "0.1", 0, "Magnitude of Oscillation");
ConVar cl_viewbob_scale_z ( "cl_viewbob_scale_z", "0.1", 0, "Magnitude of Oscillation");
then in the WalkMove function:
//view bob code
if ( cl_viewbob_enabled.GetInt() == 1 && !engine->IsPaused() )
{
float xoffset = sin( 2 * gpGlobals->curtime * cl_viewbob_timer.GetFloat() ) * player->GetAbsVelocity().Length() * cl_viewbob_scale_x.GetFloat() / 400;
float yoffset = sin( 2 * gpGlobals->curtime * cl_viewbob_timer.GetFloat() ) * player->GetAbsVelocity().Length() * cl_viewbob_scale_y.GetFloat() / 400;
float zoffset = sin( 2 * gpGlobals->curtime * cl_viewbob_timer.GetFloat() ) * player->GetAbsVelocity().Length() * cl_viewbob_scale_z.GetFloat() / 400;
player->ViewPunch( QAngle( xoffset, yoffset, zoffset));
}
//end view bob code
this way you can go in-game and test the scale x, y, and z values using the console to determine exactly where you want it. hope this helps somebody! --vecima 22:42, 11 April 2010 (UTC)