Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

reduce sideways drag rigidbody?

Discussion in 'Physics' started by Epic-Username, Jan 18, 2016.

Thread Status:
Not open for further replies.
  1. Epic-Username

    Epic-Username

    Joined:
    May 24, 2015
    Posts:
    339
    I have a object that moves by "Rigidbody.AddForce" which move it towards the direction its facing but when the object goes to turn the velocity from the direction it was going is still in effect so it slides sideways. Is there a setting or option somewhere in the rigidbody component which slows down side drag but doesn't reduce forward drag, i want it to transfer the velocity from the direction it was going into the new direction instead of sliding i cant script this because i don't know how to get and compare the direction between vectors.
     
    Last edited: Jan 18, 2016
  2. Harpoon

    Harpoon

    Joined:
    Aug 26, 2014
    Posts:
    20
    First find objects' lateral velocity then apply force in the opposite direction. Something like:
    Code (CSharp):
    1. float sidewaysdragmultiplier = 1; //how fast do you want your object to slow down
    2. Vector3 velocity = Transform.InverseTransformDirection(rb.velocity);
    3. rb.AddForce(transform.right*-velocity.x*sidewaysdragmultiplier);
     
    Oknees and torvald-mgt like this.
  3. Epic-Username

    Epic-Username

    Joined:
    May 24, 2015
    Posts:
    339
    Thanks this was helpful :).
     
    Oknees likes this.
  4. Oknees

    Oknees

    Joined:
    Oct 22, 2021
    Posts:
    7
    this also worked thanks plus it was super simple so double thanks
     
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,657
    Please use the Like button rather than necroing a nearly 7 year old thread.
     
Thread Status:
Not open for further replies.