Unity: Use Rigidbody2D's Drag to slow down flying character

Viewed 91

I have a character that gets launched into the air with
rb.AddForce(direction * punch_strength_value * punch_strength_total);

I want this character to be slowed down the higher he is in the air, creating a "soft-limit" so the character does not go too far up. I figured out this could be done by changing the Rigidbodies drag according to the character's height, but I was wrong:

 public float height_slowdown = 1;
 void Update()
 {
     heigth = transform.position.y;
     rb.drag = height * height_slowdown;
 }

Using this, the character launches into the air and is then slowed down very abruptly as if there was an invisible wall (meaning the X value does not change anymore). He then falls very slowly to the ground.

The character starts at X:0 Y:0 if that's of any help.

How do I make the character to slow down his gain in height the higher he is?

0 Answers
Related