Basically I have a “boost jump”, Jump while in mid air and you boost (and hover), I do this by using AssemblyLinearVelocity but when testing, the jump height varies depending on FPS, what can I do to avoid this or what can use instead that isn’t effected by FPS.
This means a player with a good stable FPS can make jumps while a player with lag wont be able to, kind of kills my project if there is no solution.
I looked it up and couldn’t find any posts about it, other than people mentioning the use of FPS unlockers messing with physics, which is odd as im sure others must have encountered it.
Using AssemblyLinearVelocity to apply a boost to the player’s jump can indeed result in the jump height being affected by the frame rate, because the boost is applied over a fixed number of frames. One way to avoid this issue would be to use a different method of applying the boost that is not tied to the frame rate.
One option could be to use AssemblyAddForce to apply the boost as a one-time force, rather than a continuous velocity. This would allow the player’s jump to be more consistent, as the boost would be applied in a fixed amount regardless of the frame rate.
Alternatively, you could try using AssemblySetVelocity to set the player’s velocity directly, rather than applying a velocity boost. This would also allow the player’s jump to be more consistent, as the velocity would be set in a fixed amount regardless of the frame rate.
It’s worth noting that both of these approaches will still be affected by the player’s current velocity, so you may need to adjust the amount of force or velocity that you apply to achieve the desired jump height.
AssemblyAddForce and AssemblySetVelocity are functions in the Roblox physics engine that can be used to apply forces and set velocities on objects in the game world. Here are some resources that provide more information on these functions:
Both of these functions are part of the Assembly module, which provides a set of functions and properties for interacting with the Roblox physics engine. You can find more information on the Assembly module in the Roblox Developer Hub: Oops!
I hope these resources are helpful! Let me know if you have any other questions.
I apologize for the incorrect links. The Assembly module is not part of the Roblox Engine API, and is not documented on the Roblox Developer Hub.
The Assembly module is an internal module used by Roblox to implement the physics engine, and is not intended for use by developers. It is not recommended to use the Assembly module in your own code, as it may change or be removed in future updates to Roblox.
Instead, you should use the BodyForce and Velocity properties provided by the BodyMover and BodyVelocity objects to apply forces and set velocities on objects in your game. These properties are part of the public Roblox API and are intended for use by developers.
Here are some resources that provide more information on the BodyMover and BodyVelocity objects:
@zam_gion Please don’t plagize ChatGPT responses without telling people you’re getting your answers from ChatGPT. ChatGPT’s reponses look legitimate but are almost always wrong and a waste of people’s time. You didn’t even bother to look if the links were real (they aren’t).
@PastDays Could we see the code that moves the character? I suspect the problem is either with your code or the character controller.
The character controller has downwards force thing that makes characters stick to the ground even when a force (greater than gravity) is pulling them upwards. This sticking force is probably FPS dependent. You might want to use a LinearVelocity to add the velocity so the required force is used to change the velocity. You could just create the LinearVelocity, set the LinearVelocity’s velocity, parent the LinearVelocity, and destroy it after a second (it would only need about a tenth of a second to reach the correct velocity).
Sure, though the code works fine, I’m not entirely sure what you mean but I can give LinearVelocity another go, but it just wasn’t working how i’d like it too.
------------------------------------------------------------------------------------------------------------
---[SERCIVES]
local UserInputService = game:GetService("UserInputService")
------------------------------------------------------------------------------------------------------------
---[LOCALS]
local Player_Movement = script.Parent
local Movement_Values = Player_Movement.Movement_Values
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Boosting = false
local Cool_Down = false
local Initial_Boost = 30
local Hover_Boost = 6.2
------------------------------------------------------------------------------------------------------------
---[BOOST JUMP]
UserInputService.InputBegan:Connect(function(inst, gameProcessedEvent)
if inst.KeyCode == Enum.KeyCode.Space and Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall and Cool_Down == false and not gameProcessedEvent then
--# DEBUG
print("Double Space Down")
--# Begin Setup For Boosting
Boosting = true
Character.Humanoid.JumpHeight = 0
Character.Boost_Backpack.Boosting_Sound:Play()
--# Show Boosting Visuals
Character.Boost_Backpack.Left_Node.Water_Jet_Particles.Enabled = true
Character.Boost_Backpack.Left_Node.Water_Jet_Particles_2.Enabled = true
Character.Boost_Backpack.Left_Node.Water_Jet_Particles_3.Enabled = true
Character.Boost_Backpack.Right_Node.Water_Jet_Particles.Enabled = true
Character.Boost_Backpack.Right_Node.Water_Jet_Particles_2.Enabled = true
Character.Boost_Backpack.Right_Node.Water_Jet_Particles_3.Enabled = true
--# Begin To Hover Character
local HRP = Character.HumanoidRootPart
local HRP_ALV = HRP.AssemblyLinearVelocity
Character.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(HRP_ALV.X, Initial_Boost, HRP_ALV.Z)
while Boosting == true and Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall do wait()
local HRP_ALV_NEW = HRP.AssemblyLinearVelocity
Character.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(HRP_ALV_NEW.X, HRP_ALV_NEW.Y + Hover_Boost, HRP_ALV_NEW.Z)
end
--# Clean Up Once Landed
Cool_Down = true
Boosting = false
Character.Boost_Backpack.Left_Node.Water_Jet_Particles.Enabled = false
Character.Boost_Backpack.Left_Node.Water_Jet_Particles_2.Enabled = false
Character.Boost_Backpack.Left_Node.Water_Jet_Particles_3.Enabled = false
Character.Boost_Backpack.Right_Node.Water_Jet_Particles.Enabled = false
Character.Boost_Backpack.Right_Node.Water_Jet_Particles_2.Enabled = false
Character.Boost_Backpack.Right_Node.Water_Jet_Particles_3.Enabled = false
Character.Boost_Backpack.Boosting_Sound:Stop()
while Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall do wait() end
Character.Humanoid.JumpHeight = 7.2
Cool_Down = false
end
end)
UserInputService.InputEnded:Connect(function(inst)
if inst.KeyCode == Enum.KeyCode.Space then
--# DEBUG
print("Space Up")
if Boosting == true then
Cool_Down = true
Boosting = false
Character.Boost_Backpack.Left_Node.Water_Jet_Particles.Enabled = false
Character.Boost_Backpack.Left_Node.Water_Jet_Particles_2.Enabled = false
Character.Boost_Backpack.Left_Node.Water_Jet_Particles_3.Enabled = false
Character.Boost_Backpack.Right_Node.Water_Jet_Particles.Enabled = false
Character.Boost_Backpack.Right_Node.Water_Jet_Particles_2.Enabled = false
Character.Boost_Backpack.Right_Node.Water_Jet_Particles_3.Enabled = false
Character.Boost_Backpack.Boosting_Sound:Stop()
while Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall do wait() end
Character.Humanoid.JumpHeight = 7.2
Cool_Down = false
end
end
end)
LinearVelocity basically uses as much force as necessary to change the velocity. This means it can counteract the ground force the character controller has.
This bit is frame rate dependent, but I don’t see how that would significantly affect the result unless the frame rate is like 10 fps. You could use events, but I don’t think that would change the result. The rest of the code looks good.
Edit: The problem was that the code was adding to the velocity every wait(), which is based on the frame rate. (I thought the code was just setting the velocity.)
Yea, seems like that is exactly my problem, I use a little script (I did not make it) to limit my FPS to test for things.
local Player = game.Players.LocalPlayer
script.Parent = nil
local Frames_per_second = 20
while game:GetService("RunService").RenderStepped:Wait() do
local t0 = tick()
game:GetService("RunService").Heartbeat:Wait()
repeat until (t0+1/Frames_per_second) <= tick()
end
Even at 50 fps the boost height has changed enough to decide whether you make the jump or not, I’ll try a faster loop to see if that helps or not.
I know BodyVelocities are depreciated, but maybe try this code:
------------------------------------------------------------------------------------------------------------
---[SERCIVES]
local UserInputService = game:GetService("UserInputService")
------------------------------------------------------------------------------------------------------------
---[LOCALS]
local Player_Movement = script.Parent
local Movement_Values = Player_Movement.Movement_Values
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Boosting = false
local Cool_Down = false
local Initial_Boost = 30
local Hover_Boost = 6.2
------------------------------------------------------------------------------------------------------------
---[BOOST JUMP]
UserInputService.InputBegan:Connect(function(inst, gameProcessedEvent)
if inst.KeyCode == Enum.KeyCode.Space and Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall and Cool_Down == false and not gameProcessedEvent then
--# DEBUG
print("Double Space Down")
--# Begin Setup For Boosting
Boosting = true
Character.Humanoid.JumpHeight = 0
Character.Boost_Backpack.Boosting_Sound:Play()
--# Show Boosting Visuals
Character.Boost_Backpack.Left_Node.Water_Jet_Particles.Enabled = true
Character.Boost_Backpack.Left_Node.Water_Jet_Particles_2.Enabled = true
Character.Boost_Backpack.Left_Node.Water_Jet_Particles_3.Enabled = true
Character.Boost_Backpack.Right_Node.Water_Jet_Particles.Enabled = true
Character.Boost_Backpack.Right_Node.Water_Jet_Particles_2.Enabled = true
Character.Boost_Backpack.Right_Node.Water_Jet_Particles_3.Enabled = true
--# Begin To Hover Character
local HRP = Character.HumanoidRootPart
local HRP_ALV = HRP.AssemblyLinearVelocity
local bv = Instance.new("BodyVelocity")
bv.Velocity = Vector3.new(HRP_ALV.X, Initial_Boost, HRP_ALV.Z)
bv.Parent = Character.HumanoidRootPart
while Boosting == true and Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall do wait()
local HRP_ALV_NEW = HRP.AssemblyLinearVelocity
bv.Velocity = Vector3.new(HRP_ALV_NEW.X, HRP_ALV_NEW.Y + Hover_Boost, HRP_ALV_NEW.Z)
end
bv:Destroy()
--# Clean Up Once Landed
Cool_Down = true
Boosting = false
Character.Boost_Backpack.Left_Node.Water_Jet_Particles.Enabled = false
Character.Boost_Backpack.Left_Node.Water_Jet_Particles_2.Enabled = false
Character.Boost_Backpack.Left_Node.Water_Jet_Particles_3.Enabled = false
Character.Boost_Backpack.Right_Node.Water_Jet_Particles.Enabled = false
Character.Boost_Backpack.Right_Node.Water_Jet_Particles_2.Enabled = false
Character.Boost_Backpack.Right_Node.Water_Jet_Particles_3.Enabled = false
Character.Boost_Backpack.Boosting_Sound:Stop()
while Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall do wait() end
Character.Humanoid.JumpHeight = 7.2
Cool_Down = false
end
end)
UserInputService.InputEnded:Connect(function(inst)
if inst.KeyCode == Enum.KeyCode.Space then
--# DEBUG
print("Space Up")
if Boosting == true then
Cool_Down = true
Boosting = false
Character.Boost_Backpack.Left_Node.Water_Jet_Particles.Enabled = false
Character.Boost_Backpack.Left_Node.Water_Jet_Particles_2.Enabled = false
Character.Boost_Backpack.Left_Node.Water_Jet_Particles_3.Enabled = false
Character.Boost_Backpack.Right_Node.Water_Jet_Particles.Enabled = false
Character.Boost_Backpack.Right_Node.Water_Jet_Particles_2.Enabled = false
Character.Boost_Backpack.Right_Node.Water_Jet_Particles_3.Enabled = false
Character.Boost_Backpack.Boosting_Sound:Stop()
while Character.Humanoid:GetState() == Enum.HumanoidStateType.Freefall do wait() end
Character.Humanoid.JumpHeight = 7.2
Cool_Down = false
end
end
end)
(BodyVelocities are faster to code/create than LinearVelocities)
(The body velocity can potentially use infinite force to meet the velocity, so the velocities should be the same regardless of framerate.)