'Acceleration' effect?

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.

1 Like

Do you want it to keep increasing or just to a certain point?

1 Like

You can simply tween numbers with TweenService.

1 Like

I want it to accelerate to a certain point, having it just keep going would be wild.

Wouldn’t it be weird if everyone was just at the same speed though?

1 Like

¿What do you mean by everyone?

1 Like

everyone playing in game, using a tween would eventually set everyone to have a similar P, no?

I don’t understand what you’re trying to say…

1 Like

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.

He doesn’t mean tween everyones, I think he means per person so you would probably put this in a characteradded event.

oh i see, is that the only solution, or did you have one as well?

1 Like

My solution was to lerp based on time. (tweening is your best bet though)

1 Like

How would you do that?

Sure but multiple solutions is nice though.

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)
1 Like

so I can multiply bp.P by speed and then ill be able to create the acceleration effect?

It basically just interpolates between default speed and max speed based on how long acceleration has been enabled.

1 Like

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. )

so I would do:

speed = lerp(50000, 1000000, 15)
bp.P = speed

If not what would I do?

1 Like

I would recommend using that script I sent and replace default with default and maxspeed with maxspeed and setting bp.p directly.