How would I implement Source Engine movement into my game?

Hello devs. I’m working on some sort of Counter Strike: Source-like game and bhopping and air strafing is important feature of CS:S, so I wanted to make Source-like movement but I don’t know how, any help would be appreciated.

1 Like

Before even starting with bhop start with making a movement system first walking A to B.

This system will need to have some values you can play around with that source engine has such as friction airfriction and acceleration.

One example could be my physics based system (Advertising yay) which has ground friction, air friction, and forces for movement and acceleration, also it has a way to detect if you are grounded or not.

Other systems simply may not even use physics and manually simulate it by having a variable for acceleration and += adding onto it in code.

Like the one that was suggested in your previous post:

Even the source-sdk does this which you can see in their GitHub code adding velocity creating acceleration.

			accelspeed = sv_accelerate.GetFloat() * wishspeed * gpGlobals->frametime * player->m_surfaceFriction;
			if (accelspeed > addspeed)
			{
				accelspeed = addspeed;
			}

			for (i = 0; i < 3; i++)
			{
				float deltaSpeed = accelspeed * wishvel[i];
				mv->m_vecVelocity[i] += deltaSpeed;
				mv->m_outWishVel[i] += deltaSpeed;
			}
		}
	}

	VectorAdd (mv->m_vecVelocity, player->GetBaseVelocity(), mv->m_vecVelocity);

Then you can emulate the behavior of the source engine such as ramp sliding piece by piece. There should be a lot of articles online discussing it:

In Quake’s PM_CatagorizePosition [sic] function, we see the following code:

if (pmove.velocity[2] > 180)
{
    onground = -1;
}

That is, if the player is ever moving up at greater than 180 units (velocity index 2 is the vertical component), then the player is automatically considered ‘in the air,’ and this overrides all other ‘on ground’ checks. With this, if a player is colliding with a ramp such that their velocity along the ramp has a large enough vertical component, then they are considered in the air, and thus ground friction is simply not applied (specifically, PM_AirMove is called instead of PM_GroundMove ).

This logic made to probably conserve momentum and make the game feel smoother and created a source engine like feel.

3 Likes

Thanks for help! I’ve been trying to implement the movement using this article but it didn’t kinda work. This will help me so much!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.