public void init(worldScript _myWorldScript, int x, int y, int w, int h, int _i) { myWorldScript = _myWorldScript; posX = x; posY = y; width = w; height = h; tFactor = 0f; id = _i; currentTile = myWorldScript.getTileXY(posX, posY); myDirection = getInitialDirection(currentTile, myDirection); prevDirection = myDirection; switch (myDirection) { case directions.NORTH: transform.Rotate(new Vector3(1, 0, 0), 90f); transform.localPosition = new Vector3(transform.localPosition.x + 0.5f, transform.localPosition.y, transform.localPosition.z); nextPos = new Vector3((posX - (width / 2)) * 2 + 0.5f, 1.5f, (((posY - 1) - (height / 2)) * -1) * 2); break; case directions.SOUTH: transform.Rotate(new Vector3(1, 0, 0), 270f); transform.localPosition = new Vector3(transform.localPosition.x - 0.5f, transform.localPosition.y, transform.localPosition.z); nextPos = new Vector3((posX - (width / 2)) * 2 - 0.5f, 1.5f, (((posY + 1) - (height / 2)) * -1) * 2); break; case directions.WEST: transform.Rotate(new Vector3(1, 0, 0), 0f); transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z + 0.5f); nextPos = new Vector3(((posX - 1) - (width / 2)) * 2, 1.5f, ((posY - (height / 2)) * -1) * 2 + 0.5f); break; case directions.EAST: transform.Rotate(new Vector3(1, 0, 0), 180f); transform.localPosition = new Vector3(transform.localPosition.x, transform.localPosition.y, transform.localPosition.z - 0.5f); nextPos = new Vector3(((posX + 1) - (width / 2)) * 2, 1.5f, ((posY - (height / 2)) * -1) * 2 - 0.5f); break; } currentPos = transform.localPosition; prevPos = currentPos; }