I have a problem with delta-timing this statement, as I tried multiplying multiple parts of this statement by Roblox’s provided delta time in RunService.Stepped. However, none of the methods I try work (on lower framerates roll
is higher, on higher framerates roll
is lower)
angle
is a variable that will be either -1, or 1
So here I am asking, if anyone knows how to delta-time this motion properly. Here is the script:
local roll = 0
RunService.Stepped:Connect(function(t, delta)
roll = Lerp(roll, angle, 0.125)
roll = math.clamp(roll, -1, 1)
script.Parent.HumanoidRootPart.RootJoint.Transform = script.Parent.HumanoidRootPart.RootJoint.Transform * CFrame.Angles(0, roll * 2.5, 0)
end)
I’m sure Lerp is self explanatory, but here is the code just incase you want to see:
function Lerp(a, b, t)
return a + (b - a) * t
end
The main attempted solution I tried is multiplying 0.125 by delta but that did not work.
It will be .125*delta/targetFPS.
So, since RunService.Stepped has a target of 60 FPS, you can use this to achieve .125/second.
Actually, here’s some more stuff you need. The way you are doing it will not be linear because a
in lerp is constantly changing.
local roll = 0
local start = roll
RunService.Stepped:Connect(function(t, delta)
roll = Lerp(start, angle, 0.125*delta/60)
roll = math.clamp(roll, -1, 1)
script.Parent.HumanoidRootPart.RootJoint.Transform = script.Parent.HumanoidRootPart.RootJoint.Transform * CFrame.Angles(0, roll * 2.5, 0)
end)
Tried your solution and I tried to mix it around a bit also. It didn’t work.
See how the player tilts in the direction they are moving? roll
controls how much of that tilt actually happens. roll
is larger on slower framerates, and smaller on higher framerates. angle
I suspect may be a major problem with this, as on lower framerates angle
is higher because there is less time between calculations, and smaller on higher framerates. It sounds redundant, but even if I manipulate angle I can’t make it so it’s the same on all devices.
Isolate the problem. Use the code for something simpler besides an animation, one with easier rotations, and see if it will work. If it doesn’t, include video and all of the variables.
Also, I thought roll
was to be the angle currently set at, and angle
was to be the angle you are trying to reach? Or does angle
have a chance to change before the full rotation is finished? Might be better if I saw the full code while you are trying what I mentioned above.
I sent you the code to take a look at it. I tried many different methods. I’m starting to think that (maybe it isn’t possible) in this instance. Not a lot of people know about delta-time mathematics, especially when dealing with Roblox.
Also my internet is dying on and off so sorry if I am not responding as fast as I should be