Compensate slow fall when using rigidbody.drag
I'm making a game with ball physics and an FPS camera. I'm using rb.drag and rb.angularDrag to slow my player down in certain circumstances (eg.: while on air, while braking/crouching). Problem is, it works too well as it also slows down my player's falling speed. How do I make my player fall normally while using rb.drag?
Notes:
I've tested using rb.mass. This made controling the player worse.
I've tried
rb.AddForce(Vector3.up * -rb.drag*gravityForce);
, but falling still felt off. Either I fell so fast i could barely jump, or the player still fell at a constant speed, without accelerating.
My movement code: void Start() { DistanceToTheGround = GetComponent().bounds.extents.y; }
void Update()
{
// Input
moveFwrd = Input.GetAxis("Horizontal");
moveSide = Input.GetAxis("Vertical");
// Player Jump
onGround = Physics.Raycast(transform.position, Vector3.down, DistanceToTheGround + 0.1f);
if (onGround)
{
rb.drag = 0f;
if (Input.GetKeyDown(jumpKey))
{
rb.AddForce(Vector3.up * jumpSpeed, ForceMode.Impulse);
}
}
else
{
rb.drag = 2f;
rb.AddForce(Vector3.up * -rb.drag*6f);
}
// Braking
if (Input.GetKey(brakeKey))
{
rb.drag = brakeForce;
}
}
void FixedUpdate()
{
// Player Movement
movement = cam.transform.right * moveFwrd + cam.transform.forward * moveSide;
movement.y =0;
movement = movement.normalized;
rb.AddForce(movement * speed);
}
Your answer
Follow this Question
Related Questions
Change rigibody velocity without affecting other axis 0 Answers
How to get objects to shake and fall off in 3D,Getting an object to shake and fall off in 3D 0 Answers
How do I remove drag from a hinge joint? 0 Answers
Damage drop-off over distance on a physical projectile 1 Answer
Mass effects terminal velocity 1 Answer