Hello! so I’m making fps game but players can bhop and it’s not realistic
so I want to make jump physic like this [sorry for laggy clip]
https://cdn.discordapp.com/attachments/854227073187053618/890200199492931604/Lowkey_1632310547090.mp4
as you can see when I spam jump my movement is very slow
but for my game when I can just hold jump and It can bhop at same speed
So this is what I’ve tried so far but it’s not what I need
--settings:
local MOVE_ACCELERATION = 9
local JUMP_DIRECTION_FREEZE = true -- stop player from changing direction mid jump
local MIN_VALUE = 0.55 -- do not make less than 0.1 or character can fling into void...
---------------------------
----don't touch
local targetMoveVector = Vector3.new()
local mainMoveVector = Vector3.new()
local lX,lY,lZ = 0,0,0
---------------------------
function ControlModule:OnRenderStepped(dt)
if self.activeController and self.activeController.enabled and self.humanoid then
-- Give the controller a chance to adjust its state
self.activeController:OnRenderStepped(dt)
-- Now retrieve info from the controller
local moveVector = self.activeController:GetMoveVector()
local cameraRelative = self.activeController:IsMoveVectorCameraRelative()
local clickToMoveController = self:GetClickToMoveController()
if self.activeController ~= clickToMoveController then
if moveVector.magnitude > 0 then
-- Clean up any developer started MoveTo path
clickToMoveController:CleanupPath()
else
-- Get move vector for developer started MoveTo
clickToMoveController:OnRenderStepped(dt)
moveVector = clickToMoveController:GetMoveVector()
cameraRelative = clickToMoveController:IsMoveVectorCameraRelative()
end
end
-- Are we driving a vehicle ?
local vehicleConsumedInput = false
if self.vehicleController then
moveVector, vehicleConsumedInput = self.vehicleController:Update(moveVector, cameraRelative, self.activeControlModule==Gamepad)
end
-- If not, move the player
-- Verification of vehicleConsumedInput is commented out to preserve legacy behavior,
-- in case some game relies on Humanoid.MoveDirection still being set while in a VehicleSeat
--if not vehicleConsumedInput then
if cameraRelative then
moveVector = calculateRawMoveVector(self.humanoid, moveVector)
end
local willJump = self.activeController:GetIsJumping() or (self.touchJumpController and self.touchJumpController:GetIsJumping())
if not JUMP_DIRECTION_FREEZE or (JUMP_DIRECTION_FREEZE and not willJump) then
targetMoveVector = moveVector
end
mainMoveVector = mainMoveVector:Lerp(targetMoveVector, math.clamp(dt * MOVE_ACCELERATION, 0, 1) )
local X,Y,Z = mainMoveVector.X,mainMoveVector.Y,mainMoveVector.Z
--print(X,Y,Z," ",lX,lY,lZ)
----set minimum value (otherwise your character will be sliding)
if (X<lX and X>0 and X<MIN_VALUE) or (X>lX and X<0 and X>-MIN_VALUE) then
X = 0
end
if Y<lY and Y>0 and Y<MIN_VALUE or (Y>lY and Y<0 and Y>-MIN_VALUE) then
Y = 0
end
if Z<lZ and Z>0 and Z<MIN_VALUE or (Z>lZ and Z<0 and Z>-MIN_VALUE) then
Z = 0
end
-------------------
mainMoveVector = Vector3.new(X,Y,Z)
lX,lY,lZ = X,Y,Z
self.moveFunction(Players.LocalPlayer, mainMoveVector, false)
--end
-- And make them jump if needed
self.humanoid.Jump = willJump
end
end
If you have any idea please tell me
Thanks!