0

If i want to use Physics in Unity2D what should be the most efficient way to move the object without interfering physics?

 1. Transform.position
 2. Rigidbody.Velocity
 3. Rigidbody.addForce
 4. Transform.translate
 5. Rigidbody.movePosition

Seems like there are a lot of ways and each way has a special purpose for when it should be used and when not. I just don't know that.

1 Answers1

1

Modifying the velocity will interfere with your physics if you're not sure of what you're doing. Ideally, you'd move things around by adding forces. Using Rigidbody2D.AddForce is the least complicated way to move objects that have a RigidBody.

House
  • 73,224
  • 17
  • 184
  • 273
  • But when you constantly add force your object's speed goes on increasing how to maintain a constant speed? – Tushar Sharma May 02 '16 at 19:59
  • Only add force until the speed is what you want, then stop adding force. – House May 02 '16 at 20:01
  • It means we can't move at a constant velocity from rest, we'll have to accelerate to that velocity? – Tushar Sharma May 02 '16 at 20:03
  • Yes, that's how physics works. There's no instantaneous changes in velocity. If you want to violate that, then you should change the velocity instead. But you'll need to account for any changes in the velocity the physics system makes, like drag, bouncing off other objects or walls, etc. You can also set a maximum velocity and have a very high acceleration. – House May 02 '16 at 20:05
  • Setting Very High Acceleration seems a nice trick. – Tushar Sharma May 02 '16 at 20:08
  • -1 adding to force does interfere with physics – Evorlor May 03 '16 at 05:47
  • 1
    @evorlor, I guess you'd have to define 'interfere'. I'd say adding forces is supplying the physics system with inputs, not interfering. Thanks for commenting about your reason. – House May 03 '16 at 05:50