ive been trying to make a system to make players keep momentum mid air (im making a parkour game inpired by beatrun and mirrors edge), ive pretty much got a good system but i cant change the direction the player flies into, making it extremely unresponsive
heres the script
game:GetService("RunService").Heartbeat:Connect(function()
if script.Parent.Humanoid.FloorMaterial==Enum.Material.Air then
local y = velocity.Y - 2.5
velocity = Vector3.new(velocity.X, y, velocity.Z)
script.Parent.HumanoidRootPart.Velocity = velocity
end
velocity = script.Parent.HumanoidRootPart.Velocity
end)
local velocity = script.Parent.HumanoidRootPart.Velocity
local magnit = velocity.Magnitude
game:GetService("RunService").Heartbeat:Connect(function()
if script.Parent.Humanoid.FloorMaterial==Enum.Material.Air then
if w==true then
velocity = Vector3.new(velocity.X, script.Parent.HumanoidRootPart.Velocity.Y, velocity.Z)
local direction = script.Parent.HumanoidRootPart.CFrame.LookVector
local desireddirection = direction / direction.Magnitude
local speed = velocity.Magnitude
velocity = desireddirection * magnit
velocity = Vector3.new(velocity.X, script.Parent.HumanoidRootPart.Velocity.Y, velocity.Z)
else
velocity = Vector3.new(velocity.X, script.Parent.HumanoidRootPart.Velocity.Y, velocity.Z)
end
script.Parent.HumanoidRootPart.Velocity = velocity
elseif script.Parent.Humanoid.FloorMaterial~=Enum.Material.Air and script.Parent.HumanoidRootPart.Velocity.Y<5 then
magnit = script.Parent.HumanoidRootPart.Velocity.Magnitude
end
print(magnit)
velocity = script.Parent.HumanoidRootPart.Velocity
end)