I’m wondering if there’s a better method to increase a LookVector by 1 until it reaches said value.
The reason why I’m asking is, my method keeps breaking my method to turn a seat.
I’ve tried multiple other methods, but they all work the same.
(I apologize in advance for the semi messed up format)
The turning method;
if Seat.Steer == 1 then
Seat.BodyGyro.CFrame = Seat.BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0,- TurnSpeed,0)
if Seat.Steer == -1 then
Seat.BodyGyro.CFrame = Seat.BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0,TurnSpeed,0)
My increase method;
if AheadValues.FullAhead.Value == true then
if BodyVelocity.Velocity.X <= FullSpeed then
BodyVelocity.Velocity = BodyVelocity.Velocity + Seat.CFrame.lookVector * 1
elseif BodyVelocity.Velocity.X >= FullSpeed then
BodyVelocity.Velocity = BodyVelocity.Velocity - Seat.CFrame.lookVector * 1
until BodyVelocity.Velocity.X == FullSpeed or AheadValues.FullAhead.Value == false
Quite literally a stupid help request, but this has been annoying me for days now.
Use vector lerping for increasing a vector3 value to a goal value.
local finalGoalVelocity = Vector3.new(0,0,0) --change this to the goal final velocity perhaps on key down
local RunService = game:GetService("RunService")
local lerpAlphaValue = math.min(deltaTime,1)
BodyVelocity.Velocity = BodyVelocity.Velocity:Lerp(finalGoalVelocity,lerpAlphaValue)
This rate of change will depend on the lerp alpha value, if set to a constant like 0.5. The velocity will increase asymptotically for example from 0-1 on every heartbeat frame it will go like:
0,0.5,0.75,0.875,…, close to 1
If you want it to increase linearly instead try doing something like this.
I got the idea from @ThanksRoBama which allows the humanoid to accelerate up to a point in a given direction.