I’ve tried making a velocity-based movement, but it didn’t go well. I need help and ideas on what to do next or solutions.
code for velocity thingy: (issue is the player slowly speeds up and the velocity is dragging the player way to change that? Is there a way to get vector forces to ignore friction?)
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player:WaitForChild("Character")
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
local Values = Character:WaitForChild("Values")
local Velocity = Instance.new("VectorForce",Character.HumanoidRootPart)
Velocity.Attachment0 = Character.HumanoidRootPart.RootAttachment
Velocity.Force = Vector3.new(0,10,0)
Character:FindFirstChildWhichIsA("Humanoid").WalkSpeed = 0
Character:FindFirstChildWhichIsA("Humanoid").JumpHeight = 0
Character:FindFirstChildWhichIsA("Humanoid"):GetPropertyChangedSignal("MoveDirection"):Connect(function()
local Speed = (Values.WalkSpeed.Value * 200)
if Values.State.Value ~= "Falling" then
print("new")
Velocity.Force = Vector3.new(Humanoid.MoveDirection.X*Speed,Velocity.Force.Y,Humanoid.MoveDirection.Z*Speed)
if Velocity.Force.Magnitude ~= 0 then
Values.State.Value = "Walking"
else
Values.State.Value = "Idle"
end
else
Velocity.Force = Vector3.new(Humanoid.MoveDirection.X*(Speed/3),Velocity.Force.Y,Humanoid.MoveDirection.Z*(Speed/3))
end
end)
Character:FindFirstChildWhichIsA("Humanoid").StateChanged:Connect(function(Old,New)
if New == Enum.HumanoidStateType.Freefall then
Values.State.Value = "Falling"
elseif New == Enum.HumanoidStateType.Landed then
Values.State.Value = "Idle"
end
end)
Character.Values.State.Changed:Connect(function(Value)
if Value == "Falling" then
Velocity.Force = Vector3.new(Velocity.Force.X,10,Velocity.Force.Z)
end
end)