# [Solved]My Friction wont work

Attention Topic was automatically imported from the old Question2Answer platform.

Hi Guys,
First, sorry for my Bad English.
Im new on Godot, and i try to move my Character Smooth, but, it wont work, and i dont understand why.

Hope you can help me!

Heres the Code:

``````#Physic
var pSpeed = 180
var pJumpspeed = -180
var pGravity = 400
var pState = "Idle"
var pDir = 1
var pVelocity = Vector2()
var pFriction = 0.25
var pAcceleration = 0.5

func get_input():
pVelocity.x = 0

if pState == "Idle":
if Input.is_action_pressed("kRight"):
pDir = 1
pState = "Walk"
if Input.is_action_pressed("kLeft"):
pDir = -1
pState = "Walk"

if pState == "Walk":
if Input.is_action_pressed("kRight"):
pDir = 1
if Input.is_action_pressed("kLeft"):
pDir = -1
if !Input.is_action_pressed("kRight") and !Input.is_action_pressed("kLeft"):
pState = "Idle"

func get_speed():
if pState == "Walk":
pVelocity.x = lerp(pVelocity.x, pDir * pSpeed, pAcceleration)
if pState == "Idle":
pVelocity.x = lerp(pVelocity.x, 0, pFriction)
print(pVelocity)

func _physics_process(delta):
get_input()
get_speed()
pVelocity.y += pGravity * delta
pVelocity = move_and_slide(pVelocity, Vector2.UP)
``````