0
votes

I need a method for accelerating the addforce method to the object.

Force Result feels too slow and I want it to be applied faster and for the final result time lapse shorten.

void FixedUpdate()
{....     
    Vector3 v_x = new Vector3(keyb_x, 0, 0);
    Vector3 force_ = v_x * kspeed * Time.deltaTime;
    float speed = rigidbody.velocity.magnitude;

    rigidbody.AddForce(force_, ForceMode.Impulse);
 ....}

Raising gravity from -9 to -19 or more in the y direction gives the expected result, but all other objects are affected. I want only it to apply to a specific object only.

2

2 Answers

2
votes

All gravity does is apply a downward force to all of your rigidbodies every physics update. For 2D unity physics you could use rigidbody2D.GravityScale, which scales gravity's effect on a per-rigidbody basis, but for 3D rigid bodies you should apply a constant force equal to the change in gravity you want for your object

e.g.

//adds a downforce of 10 per second
rigidbody.AddForce(Vector3.down * 10f * Time.fixedDeltaTime);

You'll want to put this in your fixed update function.

0
votes

object_Rigid2D.gravityScale += gravity_Increase * Time.deltaTime;