MAyno16 it glitches everytime

Also could you give a description of exactly what and how 'glitches'?

    Megalomaniak the problem is the chasing phase and the direction the ennemy is facing. it does seem to work only when it detects me from the left but when it detects me from the right he flips to the other side, and i don't know exactly what part of my code did the problem

    Have you tried using breakpoints to debug it during runtime?

    ps. the video doesn't work for me, but I also have js/script blocking add-on installed on my browser so it could be that I didn't give the necessary privileges to the right thing.

    There is a godot behavior tree plugin on github called beehav, which will make your life a lot easier if you could intergrate,it into your exist AI codes.

      MagickPanda
      it was hard to understand how to integrate it into my own project because the developper didn't explain how it actually works. He did demonstrate its usage on his personal project tho. Can you suggest any documentation or tutorial please ?

        MAyno16
        Just take a look at his tutorial example demo's video here:

        In this video's comment area there are also more videos targetting wider audience and newbie godot devs.

          MagickPanda
          Thank you very much but i actually got the code fixed on my own. Nevertheless, i will definitely try Beehave
          Here is the Reworked chase code part:

          func chase_player():
          	var direction = (player.position - position).normalized()
          	if $Vision.is_colliding() and is_on_floor() and !is_chasing:
          		last_dir = direction.x
          		is_chasing = true
          	if is_chasing:
          		if abs(last_dir-direction.x)>abs(last_dir) and not(flipped):
          			flipped = true
          			flipSK()
          		elif abs(last_dir-direction.x)<abs(last_dir) and flipped:
          			flipped = false
          			flipSK()
          		motion.x = direction.x * CHASE_SPEED
          		motion.y += GRAVITY
          		motion = move_and_slide(motion,Vector2.UP)
          		if abs(direction.x) > 0.9998:
          			is_chasing = false
          func flipSK():
          	$AnimatedSprite.flip_h = not($AnimatedSprite.flip_h)
          	$HoleChecker.position.x = -$HoleChecker.position.x
          	$PlayerChecker.scale.x = -$PlayerChecker.scale.x
          	$AttackChecker.scale.x = -$AttackChecker.scale.x
          	$Vision.rotation_degrees = -$Vision.rotation_degrees

            MAyno16 That's good to know,you finally got it working.
            Ultimately beehave will make ai behaviors more manageable and maintain–able, though plugging it into exist codes can be rather frustrating, I am also trying to use beehave as my game's individual unit AI, and It's taking alot more efforts compare to a primitive state machine stuff, but imo it will pay off in a long run.

            18 days later

            MAyno16 I will write up some better explanations on how to use the addon. I agree, while I show how to use it, I am not explaining the reasoning/logic for people to come up with their own behaviour trees.