private void PlayerKeyListner() { if (Input.GetKeyDown(KeyCode.LeftArrow)) { //double due to each block taking up 2 pixels worth of units totalAmountToMove = Mathf.Clamp(transform.position.x - amountToMove, leftMaxWallLocation, max: rightMaxWallLocation); if (datamanager.GridCellFull((float)Math.Round(totalAmountToMove), (float)Math.Round(transform.position.y))) { return; } if (datamanager.PotentialOverlapDetected(totalAmountToMove, spriteRender.bounds.min.y)) { return; } transform.position = new Vector3(totalAmountToMove, transform.position.y); movementSound.Play(); } else if (Input.GetKeyDown(KeyCode.RightArrow)) { //amountToMove = 2.57f; totalAmountToMove = Mathf.Clamp(amountToMove + transform.position.x, leftMaxWallLocation, max: rightMaxWallLocation); if (datamanager.GridCellFull((float)Math.Round(totalAmountToMove), (float)Math.Round(transform.position.y))) { return; } if (datamanager.PotentialOverlapDetected(totalAmountToMove, spriteRender.bounds.min.y)) { return; } //Debug.Log((float)Math.Round(totalAmountToMove, 1) + "," + (float)Math.Round(transform.position.y, 1) + " is not contained"); transform.position = new Vector3((float)Math.Round(totalAmountToMove, 1), (float)Math.Round(transform.position.y, 1)); movementSound.Play(); } else if (Input.GetButton("Vertical") && transform.position.y > bottomOfMap && !BottomBlockHit()) { transform.position -= new Vector3(0f, 0.01f); } }