#Strange behavior

1 messages · Page 1 of 1 (latest)

glass thorn
winged stream
#

You should check if the enemy is colliding with a wall, if your enemy is a CharacterBody you can use the property is_on_wall(), and have a boolean to disable movement when it is

#

this will fix the flickering of the enemy moving left and right every frame

glass thorn
#

because it's happening the same thing

glass thorn
#

well, my code is a mess anyway, probably gonna redo all tomorrow, but I really wanted to fix this

winged stream
glass thorn
winged stream
#

It seems like the enemy does stop moving when it hits a wall but however you determine the sprites flip_h must be wrong

#

ah its in your code

#

let me look

#

I think if you print your direction every frame, its going to be flipping back and forth when it hits a wall.
if !right_leg.is_colliding() or right_side.is_colliding(): direction = -1 elif !left_leg.is_colliding() or left_side.is_colliding(): direction = 1

#

I dont know what this bit of code is for but it probably causes the direction flipping every frame if i had to guess

glass thorn
#

And vice versa

winged stream
#

I think you should have print statements inside of your leg conditions, to see if your getting the behaviour you expect out of them

#
        print("RIGHT COLLIDE")
        direction = -1
    elif !left_leg.is_colliding() or left_side.is_colliding():
        print("LEFT COLLIDE")
        direction =  1```
glass thorn
#

but it still trys to attack me

#

and if I move to the right, he pass the collision

#

like this

#

I think I just gonna do the enemy AI from scratch

#

it's easier