Version: 2017.2
public static float Atan2 (float y, float x);

Descripción

Devuelve el ángulo en radianes cuya Tan es y/x .

Return value is the angle between the x-axis and a 2D vector starting at zero and terminating at (x,y).

Note: This function takes account of the cases where x is zero and returns the correct angle rather than throwing a division by zero exception.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform target; void Update() { Vector3 relative = transform.InverseTransformPoint(target.position); float angle = Mathf.Atan2(relative.x, relative.z) * Mathf.Rad2Deg; transform.Rotate(0, angle, 0); } }