As the titles says, when my ai hits the wall on the right he turns left.. good. but when he hits the wall on the left he gets stuck at left.
ive checked the code many times but cant seem to find where its happening.
if a fresh pair of eyes can take a look and give me some insight it would be much appreciated.
extends KinematicBody2D
var speed=100
var hp
var levelStart = 0
var is_hit = 0
var motion
var facing_left
var facing_right
onready var sprite = get_node("Sprite")
var anim = "Idle"
func _ready():
set_fixed_process(true)
set_process_input(true)
pass
func _fixed_process(delta):
print(facing_left," ", facing_right)
if (levelStart == 0):
anim = "Walk"
facing_left = true
levelStart = 1
if (anim == "Walk"):
if (facing_left == true):
motion = Vector2(-1,0)
sprite.set_flip_h(true)
if (facing_right == true):
motion = Vector2(1,0)
sprite.set_flip_h(false)
if (facing_left):
facing_right = false
if (facing_right):
facing_left = false
if (facing_left == true and self.is_colliding()):
facing_right = true
if (facing_right == true and self.is_colliding()):
facing_left = true
motion = motion*speed*delta
move(motion)
sprite.play(anim)
pass