Godot Version
4.4
Question
i have this code
if velocity.x > 0 and not facing_right:
facing_right = true
scale.x = 5 # flip to face right
elif velocity.x < 0 and facing_right:
facing_right = false
scale.x = -5 # restore original (left-facing)
And this image is my enemy scene.
My enemy is facing left by default; my enemy is messed up by facing the wrong way. So the enemy moves to the left but facing right.
i don’t know why it keeps doing it. i tried facing him the other way, flipping the sprite, but it keep messed up when moving on the navigation region. Could the navigation region be involved here? I don’t think it should because the enemy is traveling on it fine, it’s just the facing is wrong,g but I have no idea why this keeps getting messed up
Seems like your enemy is offset from the scene’s origin, that can affect how it moves. Is your Sprite2D’s position
0, 0?
i set enemy obj as origin so i can move other objects around the scene. and no my sprite position is not 0, 0 because I had to modify its scale and position it with my enemy, but I will try to rearrange it to 0, 0 as a child to enemy and move the enemy character only
sprite position set to 0, 0 dont seem to work. i also tried it on my enemy characterbody2D, the object still seem to face wrong way. its not the sprite problem because when I test then I see enemy does not chase when facing away from player, cause the detection zone is on the face side so if enemy back is towards the player, no chase happen, meaning its not a sprite issue, its the enemy object issue
i managed to fix it. i placed a root node as child to enemy and then placed detection and sprite as children of that root. now it works. so now this controls the flip only and wont conflict with other things