So I have this skidding system in my platformer project. It works, but it does it from a standstill, so it looks like the player is walking backward for a split second. as well. How can I prevent skidding from happening from a standstill?
Here's the code in question:
if Input.is_action_pressed("Right"):
if velocity.x < 200 and velocity.x > 0:
$Sprite.play("Skidding")
sideFlipActivate = true
$Sprite.flip_h = true
else:
sideFlipActivate = false
velocity.x = lerp(velocity.x, speed, 0.1)
$Sprite.play("Walking")
if velocity.x > 200:
$Sprite.flip_h = false
elif Input.is_action_pressed("Left"):
if velocity.x > -200:
sideFlipActivate = true
$Sprite.play("Skidding")
$Sprite.flip_h = false
else:
sideFlipActivate = false
velocity.x = lerp(velocity.x, -speed, 0.1)
$Sprite.play("Walking")
if velocity.x < -230:
$Sprite.flip_h = true
else:
$Sprite.play("Idle")
velocity.x = lerp(velocity.x,0,0.3)