Im trying to use the distance formula to find the distance between the player and the enemy, does anyone know why this might not work I keep getting errors:
error: CS0236: A field initializer cannot reference the nonstatic field, method, or property `ZombieLogic.Y’ (And same thing happens with X)
public GameObject enemy;
public GameObject player;
float y2 = player.transform.position.y;
float y1 = enemy.transform.position.y;
float x2 = player.transform.position.x;
float x1 = enemy.transform.position.y;
float newY = y2 - y1;
float newX = x2 - x1;
float Y = newY * newY;
float X = newX * newX;
float Answer = Y + X;
float Distance = Mathf.Pow (Answer,Answer);