plz can anyone help my this is the script
extends KinematicBody2D
var motion = Vector2()
var speed = 150
var gravity = 100
var dir = -1
func _ready():
pass
func process(delta):
motion = moveand_slide(motion,Vector2.UP)
pass
func physicsprocess(delta):
motion.x = speed * dir
if isonwall():
dir *= -1
$Sprite.flip_h = !$Sprite.flip_h
if is_on_floor() == false:
motion.y += gravity
pass
the problem here the enemy gliching in the wall and go left and right in the same place
What should I do ?