In this case I’m trying to tweak the physics engine a bit so all additional momentum gained from objects like conveyors or boosts is maintained horizontally until the player lands. I’ve never had to lay a finger on the physics engine for any of my game so I figure I’d drop by here.
Current (LocalScript, StarterPlayerScripts)
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local function onStateChanged(oldState, newState)
-- if changes state
if oldState == Enum.HumanoidStateType.Freefall and newState == Enum.HumanoidStateType.Landed then
-- read velocity
local velocity = rootPart.Velocity
-- maintain velocity
while humanoid:GetState() == newState do
rootPart.Velocity = Vector3.new(velocity.X, 0, velocity.Z)
task.wait()
end
end
end
humanoid.StateChanged:Connect(onStateChanged)
And the current conveyor script I’m using to test this (yes, this is from a free model)
local Speed = script.Parent.Speed.Value
while true do
script.Parent.Velocity = script.Parent.CFrame.LookVector*Speed
wait(0.1)
end
No clue where to start, frankly…
Current performance:
