Float subtraction returning 0

float uX = gameObject.GetComponent<Transform> ().position.x;
        float uY = gameObject.GetComponent<Transform> ().position.y;
        float aX = toAttack.GetComponent<Transform> ().position.x;
        float aY = toAttack.GetComponent<Transform> ().position.y;

        float calcX = (float)((float)aX - (float)uX);
        float calcY = aY - uY;
        Debug.Log ("Vector calc " + calcX);

I’ve tried several different methods in subtraction this sum, but whatever I seem to do it returns 0. Any ideas? It probably something very simply

What are the individual values of uX and aX? If they re very close, you may need to increase the precision of your output, e.g. by using:

Debug.Log (Vector calc " + calcX.ToString ("X.XXXX"));

This will give you four digits after the coma.

Remark: You don’t need all those (float) conversions.

Ah never mind, it me being stupid again. toAttack is cast to the same as the gameObject, that why I keep getting 0. I was adding the (float) because it wasn’t working. Thanks for the elp!