// Update is called once per frame void Update() { if (canMove) { if (controller.lookU.down) { rot.setUp(); } else if (controller.lookR.down) { rot.setRight(); } else if (controller.lookD.down) { rot.setDown(); } else if (controller.lookL.down) { rot.setLeft(); } xDir = 0; yDir = 0; if (controller.moveU.down) { yDir = 1; } else if (controller.moveR.down) { xDir = 1; } else if (controller.moveD.down) { yDir = -1; } else if (controller.moveL.down) { xDir = -1; } //Only move if the player isn't already if (xDir != 0 || yDir != 0) { int newX = position.x + xDir; int newY = position.y + yDir; //RaycastHit2D result = Physics2D.Raycast(transform.position, new Vector3(xDir, yDir, 0), RAYCAST_LEN); //Debug.DrawRay(transform.position, new Vector3(xDir * RAYCAST_LEN, yDir * RAYCAST_LEN, 0), Color.cyan, 0.25f, false); //if (result.collider == null) if (master.staticMap[newX, newY] == null && master.entityMap[newX, newY] == null) { master.entityMap[position.x, position.y] = null; master.entityMap[newX, newY] = this.gameObject; xLeft = xDir; yLeft = yDir; position.x += (int)xLeft; //xLeft and yLeft SHOULD ALWAYS BE WHOLE AT THIS POINT position.y += (int)yLeft; moveTowards(); canMove = false; } } if (attackLogic.ready) { if (controller.attackU.down) { attackLogic.up(); } if (controller.attackR.down) { attackLogic.right(); } if (controller.attackD.down) { attackLogic.down(); } if (controller.attackL.down) { attackLogic.left(); } } if (controller.attackMod.down) { attackLogic.attackMode = false; } else if (controller.attackMod.up) { attackLogic.attackMode = true; } } else if (xLeft != 0 || yLeft != 0) { moveTowards(); } else { canMove = true; } }