//acceleration of the rigidbody not calculated in Unity - calculate using components of forces along slope private void UpdateAcceleration() { float resultant = forcesScript.GetParallelForce() - forcesScript.GetFriction(); //resultant along slope if (resultant < 0 || rb.velocity.z == 0) { accelerationText.text = "0"; } else { float acceleration = resultant / mass; accelerationText.text = acceleration.ToString("F1"); } }
//acceleration of the rigidbody not calculated in Unity - calculate using components of forces along slope private void UpdateAcceleration() { resultant = forcesScript.GetParallelForce() - forcesScript.GetFriction(); //resultant along slope if (resultant < 0) { accelerationText.text = "0"; //set the velocity to 0 because it shouldn't be moving rb.velocity = new Vector3(rb.velocity.x, rb.velocity.y, 0); //Unity 2017 does not have accurate friction calculation, so mass slides before it should } else { float acceleration = resultant / mass; accelerationText.text = acceleration.ToString("F2"); } }