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 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”