First of all excuse me for my bare English.
If i run the code with the commands (//) enabled it will not do the calculation (will not print “is voorbij”) (i tested this by printing a text message after the calculation is done).
With those lines of code as a command // it works fine.
Can somebody explain this to me?
public int count;
public GameObject enemy;
public Transform spawn;
void Start () {
count = (int)Time.realtimeSinceStartup;
EnemySpawnController ESC = new EnemySpawnController();
ESC.CheckIfFree();
}
public void GoTOLocation(string name) {
print ("Searching for gameobject with name:" + name);
spawn.Find ("1");
print ("x." + spawn.transform.position.x + "/" + spawn.transform.position.y);
Vector2 diff;
//diff.x = spawn.transform.position.x-gameObject.transform.position.x;
//diff.y = spawn.transform.position.y-gameObject.transform.position.y;
print ("is voorbij");
if (x != enemy.transform.position.x) { gameObject.transform.Translate(Vector2.right * diff.x); }
if (y != enemy.transform.position.y) { gameObject.transform.Translate(Vector2.up * diff.y); }
}