I made an attack animation for my player character following the melee combat tutorial on the official GDevelope YouTube channel. So I used a point to indicate where a hitbox (a red square object) should appear to.
It appears correctly on when my character is facing right (not horizontally fliped). It doesn’t appear correctly when my character is facing left (horizontally fliped) and I have no idea what’s causing it. The hitbox appears inside the character rather than infront of it.
It’s supposed to appear like this when facing right or left.

But it appears like this when facing left.

Here’s the code which is very similar to the tutorial.
What you’re experiencing is the correct behavior. It is spawning at the right location.
Keep in mind that sprite origins start from the upper left. Objects do not care if other objects are flipped (unless you tell them to be) So when your character (and it’s points) are flipped, the other object (attack collision) will spawn at the correct point…but still starting from the upper left and going to the lower right.
You can either try checking if the character is flipped, then flipping the attack collision after it’s spawn. You will not be able to spawn it flipped though. Another option might be check if the character is flipped in condtions, and then spawn it at the attack X position - the width of the collision object (You will not be able to use an expression for the width because the object doesn’t exist yet).
Personally, I would just have the attack collision object always there and adjust it’s position accordingly every frame. Then have your attack collision check also check that the character is in the right animation and frame. Then you don’t have to worry about spawning it/deleting it into the right place.
1 Like
How am I supposed to do the way you suggested at the end?
Edit: Nevermind I figured it out