What i want to do i forcefully move the players CFrame forward (which i do using this script)
HRP.CFrame *= CFrame.new(0, 0, -2)
however i want it to have an ice effect when moving forward instead of just going forward, basically causing the player to have sort of delayed movements and slide when turning.
Basically if the player is moving forward and they turn right, i want them to keep the forward momentum for like 1-2 seconds after turning.
I recommend you use move instead of multiplying CFrame
You can achieve ice effect with something like this
local previousMovementDirection = Vector3.new() -- assuming you start at rest
local lastMovedTime = time()
local iceEffectScale = 1 -- change to adjust how much to slide, lower number is less sliding
-- each time the person need to be moved: (I recommend putting the following in a frequently updated place like game:GetService("RunService").PreRender:Connect(function())
local movementDirection = Vector3.new() -- whatever it is that you originally have
local timeElapsed = time() - lastMovedTime
lastMovedTime = time()
previousMovementDirection = previousMovementDirection:Lerp(movementDirection,math.clamp(timeElapsed,0,1))
HRP.Parent:WaitForChild("Humanoid"):Move(previousMovementDirection)
for i = 4, 0, -0.01 do
local HRP = Player.Character.HumanoidRootPart
local previousMovementDirection = Vector3.new()
local lastMovedTime = time()
local iceEffectScale = 1
local movementDirection = Vector3.new(0, 0, -10)
Player.Character.Humanoid.WalkSpeed = 0
local timeElapsed = time() - lastMovedTime
lastMovedTime = time()
previousMovementDirection = previousMovementDirection:Lerp(movementDirection,math.clamp(timeElapsed,0,1))
HRP.Parent:WaitForChild("Humanoid"):Move(previousMovementDirection)
task.wait(0.01)
end
Player.Character.Humanoid.WalkSpeed = 10
but this doesnt seem to work, did i do something wrong?
maybe you can use VectorForce? Basically you just have to add VectorForce into HumanoidRootPart , make it relative to world and attach it to RootAttachment. After that you can make a script that makes VectorForce force to (0,0,hrp.CFrame.LookVector*1000) and after some time make vectorforce smaller
local HRP = Player.Character.HumanoidRootPart
local previousMovementDirection = Vector3.new()
local lastMovedTime = time()
local iceEffectScale = 1
for i = 4, 0, -0.01 do
local movementDirection = Vector3.new(0, 0, -10) -- why is this a constant? this code was made under the assumption this would be player input...
local timeElapsed = time() - lastMovedTime
lastMovedTime = time()
previousMovementDirection = previousMovementDirection:Lerp(movementDirection,math.clamp(timeElapsed,0,1))
Player.Character.Humanoid.WalkSpeed = 16 -- why would you set this to 0?
HRP.Parent:WaitForChild("Humanoid"):Move(previousMovementDirection)
task.wait(0.01)
end
Player.Character.Humanoid.WalkSpeed = 10
Assuming your goal it to accelerate the player from not moving to moving forward at 10 studs per 0.01 seconds without decelerating
what… exactly are you trying to do anyways? this seems like an XY problem
so im trying to make a charge ability in my game but i dont want it to be so choppy and i want to make the character slide whilst doing so, ive tried multiplying cframe but it gives a really choppy and bad-looking movement, and has instant turns instead of the smooth turning im looking for.
let me clear some stuff up, for the movement direction i got confused since im relatively new to coding, and walkspeed is set to 0 as the player should not be able to walk, instead they will be forcefully moved forward.