players attack area / collision shape is on right side even though player is facing the left side/wrong direction?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By chris33556

heres the problem:

as you can see the collision/ hitbox is on the right side . its all good if the player is facing the right side. however, the player still hits but facing the left direction which i don’t want it to do. how to fix this, any ideas?

here are the scripts:

hitting oildrum facing wrong way - Pastebin.com ~ this is the player script

oildrum script - Pastebin.com #this is the oilddrum script

I couldn’t see the code because the code page didn’t open

Only the player(AnimatedSprite) returns. Parents (Area2d) do not return.

try :

     if player.flip_h == true:
         $Area2d.rotation_degress = 0
     else:
          $Area2d.rotation_degress = 180
     

or
Just return area2d
not use player.flip_h

ramazan | 2022-08-09 16:25

:bust_in_silhouette: Reply From: godot_dev_

I solved this problem in the past. I had the below scene tree

Player (KinematicBody2D)

ActiveNodes (Node2D)

CollisionBoxes(Area2D)
Sprite

PlayerBodyArea (Area2D)

In my setup the player is a KinematicBody2D, where I would avoid rotating or scaling to avoid breaking the physics collisions that were managed thanks to the player’s body box PlayerBodyArea. In addition to the body box for moving around the stage, the hitboxes and hurtboxes for interacting with enenmies were stored the the Player/ActiveNodes/CollisionBoxes. Anything else (the sprite of the player , Player/ActiveNodes/Sprite) would be children of Player/ActiveNodes. That way, when I made the player face the otherway, I would just do ActiveNodes.scale.x = -1 *ActiveNodes.scale.x, this way everything (the sprite and collision boxes) would face the same direction.

Maybe this idea could help you.