I’ve not been able to implement momentum based movement into my game because of my incredibly static movement system. Here’s a demonstration of my switching walking modes (This is a visual demo, not implementation. This controls walking movement in my game)

https://gyazo.com/ca404eca7beb0de522d13089f44738d5

https://gyazo.com/2722ec66e0e7d680d4a7a3a898a210dc

Notice when the walkspeed changes it gets very jittery. I also have specific modes set for each walk state. Something based off of walkspeed would be much more useful and would drastically improve the quality of my game. I have more walk modes than the ones shown (Stuff for aiming, stopped, walking, aimingwalking, etc etc)

I’d like to move away from this state based intensity setting, but I’m not sure where to begin. I’m not exactly a math expert. Any help would be heavily appreciated <3

```
local easing = require(script:WaitForChild("Easing"))
local UI = script.Parent:WaitForChild("ScreenGui")
local renderstepped = game:GetService('RunService').RenderStepped
local AnimTime = 2.3
local lastTick = tick()
local PercentPosition = 0
local lastpercent = PercentPosition
local MotionCode = nil
local MoveIntensity = 0
local MoveDuration = 1
function startBreathing()
spawn(function()
while renderstepped:wait() do
--character.Properties.Walkspeed:update()
--game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = character.Properties.Walkspeed.position
local ElapsedTime = (tick() - lastTick)/(MoveDuration * AnimTime)
lastTick = tick()
PercentPosition = PercentPosition + ElapsedTime
local x = math.sin(math.rad((PercentPosition) * 360)) * 4
local y = math.sin(math.rad((PercentPosition * 2) * 360)) * 4
game.Workspace.Move.CFrame = game.Workspace.Core.CFrame * CFrame.new((x*MoveIntensity) * 2, (y*MoveIntensity) * 2,0)
lastpercent = PercentPosition
if PercentPosition >= 1 then
PercentPosition = 0
end
end
end)
end
function SetIntensity(newIntensity, newDuration)
spawn(function()
local NewCode = math.random(-1e9,1e9)
MotionCode = NewCode
local renderstepped = game:GetService('RunService').RenderStepped
local startIntensity = MoveIntensity
local startDuration = MoveDuration
local distance = math.abs(startIntensity - newIntensity)
local startTime = tick()
local TotalTime = math.clamp(distance, 0, .2)
if newIntensity ~= startIntensity then
while renderstepped:wait() do
local alpha = math.clamp((tick() - startTime) / TotalTime, 0, 1)
if MotionCode ~= NewCode then
break
end
MoveIntensity = easing.inQuad(alpha, startIntensity, newIntensity - startIntensity, 1)
MoveDuration = easing.inQuad(alpha, startDuration, newDuration - startDuration, 1)
if alpha >= 1 then
break
end
end
elseif startDuration ~= newDuration then
local distance = math.abs(startDuration - newDuration)
local TotalTime = distance/1.5
TotalTime = math.clamp(TotalTime, 0, .2)
while renderstepped:wait() do
local alpha = math.clamp((tick() - startTime) / TotalTime, 0, 1)
if MotionCode ~= NewCode then
break
end
MoveDuration = easing.inQuad(alpha, startDuration, newDuration - startDuration, 1)
if alpha >= 1 then
break
end
end
end
end)
end
function setWalkspeed(speed)
local S = speed
if (S >= 1) and (S <= 10) then
SetIntensity(.2,4)
elseif (S > 10) and (S <= 19) then
SetIntensity(.6,.5)
elseif S > 19 then
SetIntensity(1.8,.35)
elseif (S < 1) then
SetIntensity(.2,4)
end
end
```

I have an opensource demo here if you want to experiment: