void FixedUpdate() { // print (transform.localPosition.x+ ", " +transform.localPosition.y); if (isClimbing) // If climbing, move based on inputs and via local scale of the object you are connected { // This transform does it based on global direction (thus moving "up" will cause the player to move upwards on the scrren wile climbing the object) if (vineHorizontalSpeed > 0 && !PlayerScript.facingRight) // Flip the characters sprite if needed { PlayerScript.Flip(); } else if (vineHorizontalSpeed < 0 && PlayerScript.facingRight) { PlayerScript.Flip(); } if (Mathf.Abs(vineHorizontalSpeed) > 0) // If climbing horizontally { PlayerScript.Check_Wall(); if (!PlayerScript.hitWall) { if (HclimbingSpeed * Time.deltaTime > PlayerScript.distanceToWall) { transform.position += new Vector3(vineHorizontalSpeed * PlayerScript.distanceToWall, 0); } else { transform.position += new Vector3(vineHorizontalSpeed * HclimbingSpeed * Time.deltaTime, 0); } } } if (vineVerticalSpeed > 0) // If climbing up { PlayerScript.Check_Ceiling(); if (!PlayerScript.hitCeiling) { if (VclimbingSpeed * Time.deltaTime > PlayerScript.distanceToCeiling) { transform.position += new Vector3(0, PlayerScript.distanceToCeiling); } else { transform.position += new Vector3(0, vineVerticalSpeed * VclimbingSpeed * Time.deltaTime); } } } else // If climbing down // if(vineVerticalSpeed < 0) { PlayerScript.Check_Ground(); if (!PlayerScript.onGround) { if (VclimbingSpeed * Time.deltaTime > PlayerScript.distanceToGround) { transform.position -= new Vector3(0, PlayerScript.distanceToGround); } else { transform.position += new Vector3(0, vineVerticalSpeed * VclimbingSpeed * Time.deltaTime); } } } anim.SetFloat("verticalSpeed", Mathf.Abs(vineVerticalSpeed)); anim.SetFloat("horizontalSpeed", Mathf.Abs(vineHorizontalSpeed)); } if (anim != null) { anim.SetBool("Climbing", isClimbing); } }