#Strange behavior
1 messages · Page 1 of 1 (latest)
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
you mean like this?
because it's happening the same thing
try making like this, it didn't work :( https://pastecode.io/s/xd4ug09n
well, my code is a mess anyway, probably gonna redo all tomorrow, but I really wanted to fix this
pretty sure is_on_wall() will only return true if your applying velocity towards the wall
I made a version where if is_on_wall(), turns a bool variable to true, but it had the same results
It's like here
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
It's to see if the raycasts I putted in the enemy was colliding, so that when it hit a right wall or the right foot it's not on ground, it goes to the left
And vice versa
let me take a look
yeah...
it's it