HL1 Camera Bob in Source 2013
 

0 Members and 1 Guest are viewing this topic.

  • Citizen
  • *
  • Posts: 3
    • View Profile
In HL1 and pre-2003 HL2, there is a slight camera bob that goes up and down when player moves.

Does anybody knows how to port that camera bob to Source SDK 2013?
Last Edit: 29 Jun 2026, 11:12:33 by M370
  • *
  • Posts: 4
    • View Profile
Go to the gamemovement.cpp file(line ~64). At the beginning of the file, add the following:
// Camera Bob
ConVar cl_viewbob_enabled("cl_viewbob_enabled", "1", 0, "Oscillation Toggle", true, 0, true, 1);
ConVar cl_viewbob_timer("cl_viewbob_timer", "10", 0, "Speed ​​of Oscillation");
ConVar cl_viewbob_scale("cl_viewbob_scale", "0.05", 0, "Magnitude of Oscillation");

At the beginning of the WalkMove (line ~1905) function, add:

   if (cl_viewbob_enabled.GetInt() == 1 && !engine->IsPaused())
   {
      float xoffset = sin(gpGlobals->curtime * cl_viewbob_timer.GetFloat()) * player->GetAbsVelocity().Length() * cl_viewbob_scale.GetFloat() / 200 - 0.01;
      float yoffset = sin(2 * gpGlobals->curtime * cl_viewbob_timer.GetFloat()) * player->GetAbsVelocity().Length() * cl_viewbob_scale.GetFloat() / 500;
      player->ViewPunch(QAngle(0, yoffset, xoffset));

   }
After that, adjust the Convars values ​​to suit your settings. :D


SimplePortal 2.3.7 © 2008-2026, SimplePortal