Topic was automatically imported from the old Question2Answer platform.
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?
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.