Hey, I have a BodyPosition inserted inside of the player’s HumanoidRootPart. There is a float property of BodyPosition called ‘p’ and I want to start slowly increasing the speed, but as it is going up it goes faster and faster, creating an acceleration effect. How can I do that?
I’ve already tried repeat statements but those weren’t much help.
ok, take a game like surf, not everyone who is surfing has the same acceleration, right? The same concept applies here, not everyone should have a similar P in a case like say, a race, so, having a tween would force the game to set the P to a specific number, if that makes sense.
This might work with tweaking to your preference. (EDITED)
local time2 = 0
local enabled = false
local intensity = 0.5
function lerp(a,b,t) return a * (1-t) + b * t end
game:GetService('RunService').RenderStepped:Connect(function(dt)
if enabled then
if time2 <= 1 then
time2 += (dt * intensity)/100
else
time2 = 1
end
else
if time2 >=0 then
time2 -= dt/100
else
time2 = 0
end
end
speed = lerp(defaultspeed, maxspeed, time2)
end)
I would also recommend adding deaccel intensity as delta time is not very much so it takes a while to slow down. ( Good starting values are 50 for intensity and 70 for deacceleration intensity. )