public void CheckRotation() { if (sludge.transform.rotation.eulerAngles.z == 270) { slimeDir = SlimeDirection.isLeft; Physics2D.gravity = Vector3.zero; //print("move to Is Left"); } else if (sludge.transform.rotation.eulerAngles.z == 180) { slimeDir = SlimeDirection.isUpsideDown; Physics2D.gravity = Vector3.zero; //print("move to Is Upsdie Down"); } else if (sludge.transform.rotation.eulerAngles.z == 90) { slimeDir = SlimeDirection.isRight; Physics2D.gravity = Vector3.zero; //print("move to Is Right"); } else if (sludge.transform.rotation.eulerAngles.z == 0) { slimeDir = SlimeDirection.isNormal; Physics2D.gravity = Vector3.zero; //print("move to Is Normal"); } }
void OnTriggerStay2D(Collider2D other) { if (other.gameObject.tag == "Wall") { if (Input.GetKeyDown(KeyCode.UpArrow)) { //Climb wall to the left if (slimeDir == SlimeDirection.isNormal) { transform.Rotate(0, 0, 270); print("Left Side"); slimeDir = SlimeDirection.isLeft; } //Detach from Ceiling else if (slimeDir == SlimeDirection.isUpsideDown) { transform.Rotate(0, 0, 180); print("Normal Side Up"); slimeDir = SlimeDirection.isNormal; } } else if (Input.GetKeyDown(KeyCode.RightArrow)) { //Change from Left wall to Ceiling if (slimeDir == SlimeDirection.isLeft) { transform.Rotate(0, 0, 270); print("Upside Down"); slimeDir = SlimeDirection.isUpsideDown; } } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { //Change from Right wall to Ceiling if (slimeDir == SlimeDirection.isRight) { transform.Rotate(0, 0, 270); print("Upside Down"); slimeDir = SlimeDirection.isUpsideDown; } } } }