How to calculate Distances

Hi,

I really am sorry for the noobish nature of this question. I further apologize for essentially asking for code. What I am wondering is how can I calculate the distances between two tagged gameObjects such as “Player” and “enemy”. I am in need of this so that I can more precisely know the distance between the “Player” and the “enemy” so that I can better set up animations for fighting and what not.

Thank you for your assistance.

enemyDistance = Vector3.Distance( GameObject.FindWithTag (“enemy”).transform.position, GameObject.FindWithTag (“Player”).transform.position);

You can use Vector3.Distance to determine the distance between two objects. You can identify the two objects by tag by using GameObject.FindWithTag.