Right now I have 2 Problems:
Note: I have set all of the Character’s descendants to Massless if they are a BasePart.
Problem 1: VectorForce doesn’t seem to be applied in full when another VectorForce is being distributed (happens when I try to dash after jumping).
I’m not really sure why the Force being implemented on the person would change since the Jumping is exclusively on the Y and Dashing on the Z. I don’t know what force would be counteracting the dash.
Context:
Regular Dash:
Dash After Jump:
Problem 2: When the force of Gravity becomes greater than the Jump’s, the VectorForce is pratically just cancelling out Gravity for a small perioid of time instead of accelerating. How can I calculate the current force of Gravity to make the jump more consistent?
I have tried to add Gravity x TotalMass of the Character to the Force variable (but since they’re both constants it didn’t seem to work.)
Context:
Jump before and after Gravitational Force is larger than Jump Force:
FULL SCRIPT:
function Movement.Dash(player, t)
if player then
if not table.find(t, player) then -- Used for Debounce
if player.Character then
local HRP = player.Character:FindFirstChild("HumanoidRootPart")
if HRP then
table.insert(t, player) -- Add to debounce table
local Time = 0.75
local Force = 850
local Finished = false
local Attachment = Instance.new("Attachment")
local VectorForce = Instance.new("VectorForce")
VectorForce.Attachment0 = Attachment
VectorForce.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
VectorForce.ApplyAtCenterOfMass = true
VectorForce.Force = Vector3.new(0, 0, -Force)
local Humanoid = player.Character:FindFirstChild("Humanoid")
if Humanoid then
local Animator = Humanoid:WaitForChild("Animator")
local Animation = game:GetService("ServerStorage"):WaitForChild("Animations"):WaitForChild("Movement"):WaitForChild("Dash"):WaitForChild("Dash")
local AnimationTrack = Animator:LoadAnimation(Animation)
AnimationTrack:Play()
end
Attachment.Parent = HRP
VectorForce.Parent = HRP
task.spawn(function()
while task.wait() do
if not Finished then
if Humanoid.FloorMaterial == Enum.Material.Air then
VectorForce.Force = Vector3.new(0, 0, -(Force/1.37)) -- Divided by 1.37 to account for Friction (1.37 is just a number that worked for me, no math involved)
else
VectorForce.Force = Vector3.new(0, 0, -Force)
end
else
break
end
end
end)
for i = Force, 0, -Force/10 do
task.wait(Time/10) -- time for dash divided by 10
Force = i
end
VectorForce:Destroy()
Attachment:Destroy()
Finished = true
task.wait(2.5) -- Debounce time
table.remove(t, table.find(t, player)) -- Used for debounce
end
end
end
end
end
function Movement.DoubleJump(player, t)
if player then
if player.Character then
local Humanoid = player.Character:FindFirstChild("Humanoid")
if Humanoid then
local HRP = player.Character:FindFirstChild("HumanoidRootPart")
if HRP then
local State = Humanoid:GetState()
local WhitelistedStates = {
Enum.HumanoidStateType.Freefall,
}
if table.find(WhitelistedStates, State) then
if not table.find(t, player) then
table.insert(t, player) -- Add to debounce table
local Time = 0.34
local Force = 1080
local Attachment = Instance.new("Attachment")
local VectorForce = Instance.new("VectorForce")
VectorForce.Attachment0 = Attachment
VectorForce.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
VectorForce.ApplyAtCenterOfMass = true
VectorForce.Force = Vector3.new(0, Force, 0)
local Animator = Humanoid:WaitForChild("Animator")
local Animation = game:GetService("ServerStorage"):WaitForChild("Animations"):WaitForChild("Movement"):WaitForChild("Double Jump"):WaitForChild("Double Jump")
local AnimationTrack = Animator:LoadAnimation(Animation)
AnimationTrack:Play()
Attachment.Parent = HRP
VectorForce.Parent = HRP
for i = Force, 0, -Force/10 do
task.wait(Time/10) -- time for jump divided by 10
VectorForce.Force = Vector3.new(0, i, 0)
end
VectorForce:Destroy()
Attachment:Destroy()
local HitGroundStates = {
Enum.HumanoidStateType.Running
}
local CurrentState
repeat
task.wait()
CurrentState = Humanoid:GetState()
until table.find(HitGroundStates, CurrentState)
task.wait(1.5) -- Debounce time
table.remove(t, table.find(t, player)) -- Used for debounce
end
end
end
end
end
end
end
return Movement