lock on enemy 3d spaceshooter

Hi,

I use a ps3 controller in my spaceshooter and to aim I use the right analog stick. When my aimcursor is near an enemy, I want the cursor to snap to the enemy. To do this I use a Spherecast. If the spherecast hits an object which is in my array of enemies, I want the cursor to move to the right position (with camera.worldtoscreenpoint())
When I check if the object is in my array however, it never enters the if statement. Here’s my code:

  if(Physics.SphereCast(oRay, 5, out oHit, 500)) 
    {			
        Debug.DrawLine(oRay.origin, oHit.point, Color.yellow);  			
        print(oHit.collider.gameObject);  			
        target = oHit.point;
    
        if(enemies.Contains(oHit.collider.gameObject))			
        {				
            print("enemy found");			
        }	
    }
    else
    {
    
    //stuff
    
    }

The print shows which object the spherecast has hit. In my case it prints ‘Enemy’. In my Array I have an object ‘Enemy’. So it should also print “enemy found”, right? nope. Could anyone tell me what the problem is?

If you need more info to answer my question, just ask.

Ok so I guess I was using the Contains method wrong. I changed it to:

if(Physics.SphereCast(oRay, 5, out oHit, 500)) 
    {      
        Debug.DrawLine(oRay.origin, oHit.point, Color.yellow);           
        print(oHit.collider.gameObject);         
        target = oHit.point;

       foreach(GameObject enemy in enemies)
{


 if(oHit.collider.name.Equals(enemy.name)
    {
          print("enemy found");
    }
   }

  }
        else
        {
    
    //stuff

    }