private void RotatePlayer(RaycastHit2D hit, Vector3 dist) { float angleDif = Vector2.SignedAngle(con.transform.up, hit.normal); float playerDist = 1 - dist.sqrMagnitude / playerInitPos; //print(playerDist); con.rigid.rotation = Mathf.Lerp(con.rigid.rotation, (angleDif * Time.deltaTime) + con.rigid.rotation, playerDist); if (playerOnPlanet && Mathf.Abs(angleDif) < 2 && con.rigid.velocity.sqrMagnitude < 4 && !Input.GetButton("Thrust")) { //RotateWithPlanet(con); if (!madeJoints) { con.MakeJoints(rigid); madeJoints = !madeJoints; } con.canRotate = false; playerAction = true; PlayerAction(con.pResources); } else { madeJoints = false; con.canRotate = true; playerAction = false; } }