getting the direction of object

Im using the following script to apply damage to my enemies

if(Input.GetButton("Attack")){
		  Collider[] cols = Physics.OverlapSphere(transform.position, rang);
	
foreach (Collider col in cols){
			
			if(col.tag == "Enemy"){
				
     // if object has the right tag...
        // assuming the enemy script is called EnemyScript
		
        EnemyHealth script = col.GetComponent<EnemyHealth>();
        script.AddjustCurrentHealth(-10); // apply damage 5

This works well, but i don’t want to attack the enemy if it is behind me. how cab i get the rotation of the object so i can use it in an if statement, or is there another way to do it? Please Help

If your player has a camera you could try this: http://unity3d.com/support/documentation/ScriptReference/Camera.WorldToViewportPoint.html
and make sure his viewpoint coords are between 0 and 1 (or whatever field of view you like).

If not, you could create a vector from player to enemy, and cross-product that with the player’s forward vector. If the resulting Y component points up, he’s in front, if down, he’s behind (or something like that)