kotak tumpang tindih persatuan

//draw a hitbox in front of the character to see which objects it collides with
Vector3 boxPosition = transform.position + (Vector3.up * lastAttack.collHeight) 
        + Vector3.right * lastAttack.collDistance;
Vector3 boxSize = new Vector3 (lastAttack.CollSize/2, lastAttack.CollSize/2, hitZRange/2);
Collider[] hitColliders = Physics.OverlapBox(boxPosition, boxSize,
        transform.rotation, HitLayerMask);

...

void OnDrawGizmos(){
    if (lastAttack != null && (Time.time - lastAttackTime) < lastAttack.duration) {

        // cache previous Gizmos settings
        Color prevColor = Gizmos.color;
        Matrix4x4 prevMatrix = Gismos.matrix;

        Gizmos.color = Color.red;
        Gizmos.matrix = transform.localToWorldMatrix; 

        Vector3 boxPosition = transform.position + (Vector3.up * lastAttack.collHeight) 
                + Vector3.right * ((int)lastAttackDirection * lastAttack.collDistance);

        // convert from world position to local position 
        boxPosition = transform.InverseTransformPoint(boxPosition); 

        Vector3 boxSize = new Vector3 (lastAttack.CollSize, lastAttack.CollSize, hitZRange); 
        Gizmos.DrawWireCube (boxPosition, boxSize);

        // restore previous Gizmos settings
        Gizmos.color = prevColor;
        Gizmos.matrix = prevMatrix;
    }
}
Vast Vendace