Q:

How to find nearest gameobject on one side

Here is an example:

The left enemy robot is closer than the right enemy robot, but I want the character to attack the robot that is closest to him on his right side. I can't use Physic.SphereCast or anything of that sort because it will just find the closest enemy on both sides. How can I make this happen?

A:

The best way to do this depends on a few things. I'm going to assume the following - if any of these are incorrect, please let me know and I'll update my answer:

You want the closest enemy that is anywhere to the right of the player within a certain range, even if it is at a different height
You want true distance, not just the one that is closest in horizontal positioning (eg an enemy one unit to the right is closer than an enemy one unit to the right and one unit above)

Here's what I'd suggest as a solution:
using UnityEngine;
using System.Linq;
using System.Collections.Generic;

public class YourBotClass : MonoBehaviour {

    float sightRange = 15;

    //
    // Your class code here
    //

    Collider2D GetClosestEnemy(bool facingRight) {
        Vector2 pos = transform.position;
        IEnumerable<Collider2D> validTargets;

        // Get all targets in range
        // Note:  You'll probably want to add a layermask to the OverlapCircleAll call
        var targets = Physics2D.OverlapCircleAll(pos, sightRange);

        if (facingRight) {
            // Filter results to only include targets to the right                
            validTargets = targets.Where(coll => coll.transform.position.x >= pos.x);
        } else {
            // Filter results to only include targets to the left
            validTargets = targets.Where(coll => coll.transform.position.x <= pos.x);
        }

        // I've broken the return statement into multiple lines for easier readability
        return validTargets
            // Sort targets by distance
            .OrderBy(coll => Vector2.Distance(pos, coll.transform.position))
            // Return first result, or null if no valid targets
            .FirstOrDefault();

    }
}

