I’m trying to learn how to rig a car following Sleitnick’s tutorial How to rig a car . I have one question that i want to ask? How can the steering speed be calculated in this way:
> local steergoal = -seat.SteerFloat * 30
> local steer = steer + (steergoal-steer) * math.min(deltatime*seat.TurnSpeed,1)
i have little experience in runservice and anything related to this service so please go easy on me.
The deltaTime parameter basically provides a parameter between each event (take this with a grain of salt, not an expert on this).
Try running this code in the command bar: local e = game["Run Service"].Heartbeat:Connect(function(deltaTime) print(deltaTime) end) wait(5) e:Disconnect()
This basically prints the deltaTime to help you visualize it.
Here’s a random tutorial I found, hope it helps.
Nope no calculations involved really, what it does is lerp the current steer towards the goal steel.
local function lerp(start, goal, alpha)
return start + (goal - start) * alpha
end
--Notice the similarities with the below steer equation?
--local steer = steer + (steergoal-steer) * math.min(deltatime*seat.TurnSpeed,1)
--alpha is equal to
--deltatime*seat.TurnSpeed
@ThanksRoBama explains the equations behavior and hence it’s purpose in another similar post:
TL;DR:
Provide responsive fast controls but doesn’t directly go towards the goal so you can do stuff like tapping input in order to control the car better at small turn speeds.
and the part you say about it gets closer to the target speed, it accelerates slower and slower. What do you mean by that? it starts to get really confused now.