extends KinematicBody2D onready var RightLedgeCheck: = $RightLedgeCheck onready var LeftLedgeCheck: = $LeftLedgeCheck onready var colisionPolygon: = $CollisionPolygon2D var direction = Vector2.RIGHT var velocity = Vector2.ZERO # Called when the node enters the scene tree for the first time. func _ready(): pass # Replace with function body. func _physics_process(delta): var found_wall = is_on_wall() var found_ledge = not RightLedgeCheck.is_colliding() var found_left_ledge = not LeftLedgeCheck.is_colliding() if found_wall or found_ledge or found_left_ledge: direction *= -1 if $AnimatedSprite.flip_h: $AnimatedSprite.flip_h = false colisionPolygon.position.x = -0.5 else: $AnimatedSprite.flip_h = true colisionPolygon.position.x = 0.5 velocity = direction * 25 move_and_slide(velocity, Vector2.UP)