damage direction

how can i make damage direction like this if get hit from front show image1,if hit right show image2?

public Image direction;

void update(){
     Vector3 targetPos = target.transform.position;
     Vector3 screenpos = Camera.main.WorldToScreenPoint(targetPos);
...
}

First find the point of contact - for example

Raycast:
if(Physics.Raycast(..., out hit, ...){hitPoint = hit.Point;}

Collision
void OnCollisionEnter(Collision col){ hitPoint = col.GetContact(0); }

Then find the direction between your player and the hit point

Vector3 direction = hitPoint - player.transform.position;

Then figure out which direction most matches the direction to your hit point

float frontDot = Vector3.Dot(direction, player.transform.forward);
float rightDot = Vector3.Dot(direction, player.transform.right);

if(Mathf.Abs(frontDot ) > Mathf.Abs(rightDot )){
    if(frontDot > 0) ShowFrontCollisionImage();
    else ShowBackCollisionImage();
} else{
    if (rightDot > 0) ShowRightCollisionImage();
    else ShowLeftCollisionImage();
}

Then just right up the code to show the correct image from those functions