Move Overlapbox/GameObject depending on Parent

So I’ve been making a 2D Top-Down RPG, and am currently figuring out how to do the combat. Using tutorials, I chose to do this:

Collider2D[] enemiesToDamage = Physics2D.OverlapBoxAll(attackPos.position, new Vector2(attackRangeX, attackRangeY), 0, whatIsEnemies);
        for (int i = 0; i < enemiesToDamage.Length; i++)
        {
            enemiesToDamage*.GetComponent<EnemyHealthManager>().TakeDamage(damage);*

}
However, I would like to move the “hitbox” (called “AttackPos”), depending on the direction the character is looking. How can I put this into my scripts?
I also made a string called “direction” on my PlayerMovement script, but I don’t know how to proceed.
Also, how can I rotate the OverlapBoxAll when looking to the left/right?
Sorry for any English mistakes and if this is a stupid question, I’m stuck :frowning:

You can rotate the parent in the PlayerMovementScript by using Quaternion.LookRotation().

Great! So, from your PlayerMovement script, you can access your child Game Object by using

void Start()
{
GameObject childGameObject = transform.Find("Name of your child game object");
}

The code below this goes under Update(), might be a good idea to put this inside your if (movement != Vector2.zero) block

if (movement.x > 0)
{
    childGameObject.transform.localPosition = new Vector3 (5,0);
}

if (movement.x < 0)
{
    childGameObject.transform.localPosition = new Vector3 (-5,0);
}

if (movement.y > 0)
{
    childGameObject.transform.localPosition = new Vector3 (0,5);
}

if (movement.y < 0)
{
    childGameObject.transform.localPosition = new Vector3 (0,-5);
}

Also, might want to consider changing your EmptyGameObject name to something like, I don’t know, AttackPosHolder. So, instead of childGameObject, its easier to read your code in the future by using the name attackPosHolder.