Even after setting the MaxForce to 50K, it still is slightly flinging (as shown in the second video) and can sometimes make you frog sideways (as shown in the first video). This is due to the dash being on the client, but I don't know how to fix this other than moving it to the server, which would make the game unplayable on higher ping
#BodyVelocity being buggy at low fps
1 messages · Page 1 of 1 (latest)
local Debris = game:GetService("Debris")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LocalActions = {}
local DashDirection = require(script.DashDirection)
local Euler = math.exp(1)
local function CheckStatus(Player : Player, States : {}) : Model
local Character = Player.Character
if not Character then return end
local Humanoid = Character:FindFirstChild("Humanoid")
if not Humanoid or Humanoid.Health <= 0 then return end
local CurrentState = States.States.CurrentState
if not CurrentState or CurrentState == "Stunned" then return end
return Character
end
local function GetMass(Character : Model) : number?
local Mass = 0
for i, v in Character:GetChildren() do
if not v:IsA("Part") then continue end
Mass += v:GetMass()
end
return Mass
end
local function CreateBodyVelocity(HumanoidRootPart : Part)
local BodyVelocity = Instance.new("BodyVelocity")
BodyVelocity.Parent = HumanoidRootPart
BodyVelocity.P = 100000
BodyVelocity.MaxForce = Vector3.new(50000, 0, 50000)
local DebrisTime = 0.4
Debris:AddItem(BodyVelocity, DebrisTime)
return BodyVelocity, DebrisTime
end
function LocalActions.Dash(Player : Model, GetKeysPressed : {any}, States : {any})
local Character = CheckStatus(Player, States)
if not Character then return end
DashDirection.ReturnDirection(GetKeysPressed)
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if not HumanoidRootPart then return end
local CurrentVector, Value = DashDirection.ReturnDirection(GetKeysPressed)
local Mass = GetMass(Character) * 6
local BodyVelocity, DebrisTime = CreateBodyVelocity(HumanoidRootPart)
local Time = 0
local Connection
Connection = RunService.Heartbeat:Connect(function(DeltaTime)
Time += DeltaTime
if Time >= DebrisTime then Connection:Disconnect() end
local Steepness = 0.5
local Decay = (1 + Steepness ^ 2) - (Steepness + Time) ^ 2
BodyVelocity.Velocity = HumanoidRootPart.CFrame[CurrentVector] * Mass * Decay * Value
end)
end
return table.freeze(LocalActions)
(note that this is 60 fps which isnt that low)
@lean flicker what is your ultimate goal?
To like move straight?
Without it being “buggy”
essentially yeah
i havent really worked with body velocity much as ive been more on the math side of things
I think so 100%
And make it so if the player touches something to stop the tween
That’s what I’d try
im trying to make it so that it
is a dash similar to most combat systems
and if it were to just stop instantly after hititng something
Oh ok
Yeah
maybe raycasting and slowing the dash down would work?
I think in most games they just ignore that lol
if it was close enough to an object
That’d be very expensive
i guess
but i mean its just one ray
its calculated on the client
so it wouldnt really strain the server
Yeah but one ray times how many people are in the server
Yeah I don’t see why not then
Perfect lmk if anything ping me