Hello,
I have a character that needs to change gravity and I’m trying to duplicate how Unity is applying gravity since the character has to use a consistent gravity speed as the other rigidbodies in the scene, but is not using the same direction.
In my rigidbody, I unchecked “Use Gravity” and in my code I added the line:
def FixedUpdate() {
rigidbody.AddForce(gravity * gravityDirection.normalized);
}
where gravity is the same number as the one found in the Unity Physics settings (9.81). This makes the gravity a lot lighter than how Unity is applying it, though. I don’t know the exact number, but I played around with multiplying the gravity in code and it seems if I do:
rigidbody.AddForce(gravity * gravityDirection.normalized * 4.0);
it is closer to Unity’s gravity setting, but it’s still not exact.
How can I implement gravity in my FixedUpdate function so that it matches Unity’s internal rigidbody implementation exactly?