I’m trying to cap a character’s velocity however I don’t know how to; I’m making a game with a custom movement system (PhysicsCharacterController) by @dthecoolest which has Sliding, Trimping, and Grappling (which I modified to include Bhopping and adjusted the values of attributes and trimping as such).
There’s this one glitch which I am stumped over on how to solve it, except for adding a velocity cap for the player.
You just press F and then right after Slash to open chat and somehow it registers that your still sliding and this makes you EXTREMELY fast if you just Slide and then Bhop.
I want to try and cap the velocity, so it doesn’t go over 125.
couldn’t you just check if the player’s HumanoidRootPart’s AssemblyLinearVelocity.Magnitude is greater then a cetain number, it changes the velocity to that number by welding a part to the frount of the players chest and setting the AssemblyLinearVelocity to that parts LookVector times whatever?
something like
--- I think you already have a loop above this, but if you don't this should be in one
local MaxMagnitude = 4 --fool with this number
if rootPart.AssemblyLinearVelocity.Magnitude > MaxMagnitude then
rootPart.AssemblyLinearVelocity = rootPart.PartThatsWeldedToThePlayersChest.CFrame.LookVector * MaxMagnitude
end
I haven’t tested this but maybe try inserting a LinearVelocity instance, and set the MaxForce to whatever you want. Having certain settings can make it so no velocity is given I believe.
function Slide:InputEnd()
local data : PhysicsCharacterController = self.PhysicsCharacterController
local model = data._Model
if self._AutoRotateObject then
self._AutoRotateObject.ShouldUpdate = true
end
model:SetAttribute("FlatFriction", model:GetAttribute("FlatFriction")) -- Reset friction back to normal
local waist = model:FindFirstChild("Root", true)
if waist then
waist.C0 = self._C0_ORIGINAL
end
model:SetAttribute("WalkSpeed", self._OriginalWalkSpeed)
model:SetAttribute("XZDragFactorVSquared", self._OriginalDragValue)
self._SlideAnim:Stop(1)
end
Ok so for Input End maybe try switching it to User Input Service as then you can detect if it was processed meaning it would run even when your talking or doing anything else
so idk if there is some kind of variable saying if you are sliding but you can do
game:GetService('UserInputService').InputEnded:Connect(function(input,processed)
if processed == true and Sliding == false then
return
end
if input.KeyCode == Enum.KeyCode.F then
if Sliding == true then
--Call input end
Sliding = false
end
end
end)
I have solved this by using LinearVelocity, setting its MaxForce to math.huge, making its Attachment0 to the RootAttachment in the RootPart, and just making it relative to the world and making the VectorVelocity 0,0,0 so the character can’t gain any momentum and it just cancels the slide basically. (This process happens when the character has >= 125 velocity which is deemed impossible to achieve unless somebody is using the glitch)
It gets destroyed when the game sees that the character has <= 60 velocity and has the LinearVelocity instance meaning their slide canceled out.