Hi, I am trying to fork the ControlModule script so that I can ease character movement from 0 speed to the intended. I am not doing this with WalkSpeed as I believe that will interfere with other scripts.
This is what I have so far:
local easeTime = 0.5
local vectorMult = 0
local charMove = false
function ControlModule:OnRenderStepped(dt)
if self.activeController and self.activeController.enabled and self.humanoid then
-- Give the controller a chance to adjust its state
self.activeController:OnRenderStepped(dt)
-- Now retrieve info from the controller
local moveVector = self.activeController:GetMoveVector()
local cameraRelative = self.activeController:IsMoveVectorCameraRelative()
local clickToMoveController = self:GetClickToMoveController()
if self.activeController ~= clickToMoveController then
if moveVector.magnitude > 0 then
-- Clean up any developer started MoveTo path
clickToMoveController:CleanupPath()
else
-- Get move vector for developer started MoveTo
clickToMoveController:OnRenderStepped(dt)
moveVector = clickToMoveController:GetMoveVector()
cameraRelative = clickToMoveController:IsMoveVectorCameraRelative()
end
end
-- Are we driving a vehicle ?
local vehicleConsumedInput = false
if self.vehicleController then
moveVector, vehicleConsumedInput = self.vehicleController:Update(moveVector, cameraRelative, self.activeControlModule==Gamepad)
end
-- If not, move the player
-- Verification of vehicleConsumedInput is commented out to preserve legacy behavior,
-- in case some game relies on Humanoid.MoveDirection still being set while in a VehicleSeat
--if not vehicleConsumedInput then
if cameraRelative then
moveVector = calculateRawMoveVector(self.humanoid, moveVector)
end
if moveVector > Vector3.new() then
charMove = true
task.spawn(function()
while charMove == true do
-- HELP NEEDED HERE
end
end)
else
charMove = false
vectorMult = 0
end
self.moveFunction(Players.LocalPlayer, moveVector * vectorMult, false) -- Moves the player
--end
-- And make them jump if needed
self.humanoid.Jump = self.activeController:GetIsJumping() or (self.touchJumpController and self.touchJumpController:GetIsJumping())
end
end
Please pay attention to the part where it starts with if moveVector > Vector3.new then...
I want the script to gradually increase the vectorMult
variable to 1 over a period of time set by easeTime
as long as charMove
is true, otherwise vectorMult
will reset to 0.