How would I achieve such mechanic as CSGO or Gmod Surfing?

Hi guys I just want to implement a Surfing mechanic in my project and trying to learn how would I possibly do it.
I got currently no code snippets because I got no idea if this is the wrong channel

I already made Bhopping which was confusing enough . . .


bhop system I implemented. Its a edit of a existing one

The reason Im mentioning the bhopping is actually they must be connected to eachother

There are literally no explanation on the devforum about surfing

you probably need to do something like lowering the friction

you can do this with character controllers, but you have to get rid of the humanoid to do this
https://create.roblox.com/docs/physics/character-controllers

I mean it does make sense but I would literally need to recreate the controller?

Thats why I didnt wanted to go on that path

You would have to recreate the controller, there’s no other way sadly. The other few attempts I tried were using forces but they didn’t feel close at all so I just had no other way but recreating it.

Luckily the CS:GO movement takes a lot of code from the Quake 1 source code, which is open source!
So a lot of the movement and the physics of how it works, is contained there.

But it is possible to make CS:GO movement with a humanoid, but you still have to override the built in Roblox movement by disabling it. Collisions are handled by the humanoid so you don’t have to worry about that, although you have to create your own input system.

Sadly I did lose the code for the movement system but I have a video visualizing Quake movement which is close enough to the CS movement.

Only difference with the CS:GO and Quake movement is that the speed of the player is scaled down to the desired max speed of the player. So that players, while bhopping, wont be able to move faster/gain speed from it.

Fortunately enough, it’s short so I can give you some pseudo-code about it.

function self:PreventBHop(max_accel : number)
    local max_speed = 1.1 * maxAccel
    if max_speed < 0 then return end

    local speed = self.velocity.Magnitude
    if speed <= max_speed then return end

    local fraction = max_speed / speed
    self.velocity *= fraction
end

Oh yeah and the surfing part! For that, you’d have to generate some collision ray from the player to what they’re currently standing on. And get the information from that ray to calculate the angle of the surface to offset the player from it. (I suck at explaining sorry)

But its on the Quake 1 source code on the file called “pmove.c
and the function is called “PM_ClipVelocity


But thats all I could give, I hoped this helped

1 Like

Oh wow crazy explanatory. Well I guess Im gonna re create the movement system :smiley: thank you both so much

1 Like

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