Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

rigidbody position offset?

Discussion in 'Physics' started by Innovine, Oct 10, 2018.

  1. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    168
    I have some code which moves a transform with a rigidbody attached. It seems to work fine, and I can move it to a target using a PID controller which calls AddForce() and all is working OK. But if I also perform a few AddForceAtPosition()'s then I start to see a drift, and when I move it to what should be the rest location, it arrives a little bit off to one side, as if it's developed a local transform or an offset in some way.

    Any suggestions on what's going on here?

    I am calling rigidbody.AddForce(), rigidbody.AddForceAtPosition(), and I also directly assign values to transform.rotation. Can that be the culprit? Perhaps rigidbody.MoveRotation or rigidbody.rotation are more appropriate..?

    Is there a difference between transform.rotation and rigidbody.rotation besides performance and colliders, which could result in a translational offset?
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    2,479
    Yes. If you are writting to them directly they are called at different time. Transform.rotation/position is written at given frame. While in case of RigidBody, is called when physics is calculated. So you will see differences, or even can experience jittering.

    Did you try use AddRelativeForce? Are you sure you have adding force at right position? With right force vector?

    Try use Debug.DrawLine / Ray, to see, which and where force is added.