Search Unity

RigidBody2d physic space seam tiny compared to world space

Discussion in '2D' started by Pirs01, Nov 17, 2013.

  1. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    When moving my Rigidbody2D with AddForce I must make my velocity something very big like couple of thousands to make the object move in world space any reasonable distance. Is that intended or am I missing something here?
     
  2. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    For my object to travel 1f (in world space) in one sec I need to use velocity of 2500f
     
  3. Pirs01

    Pirs01

    Joined:
    Sep 30, 2012
    Posts:
    389
    OK. It is not so at all.
    I did it wrong by assuming Rigidbody2D.AddForce to use ForceMode of VelocityChange but it doesn't so I did some stuff that didn't make sense.
    Instead of using AddForce I modify .velocity to move object with constant velocity ignoring mass and acceleration.
     
  4. Deleted User

    Deleted User

    Guest

    i made tests, and the forces are mathematically identical between the 2d and 3d physics engines, the units you are dealing with are meters, kilograms , seconds and the force you apply is in newtons

    for an object with a mass of 1 with zero linear drag and no gravity, to reach the velocity of 10 meters per second in a second you need to apply a constant force of 10 during the whole second, if you want instant acceleration with addforce, you need to multiply the value by the times per second the physics updates, for example i use a fixed time step of 16 miliseconds so 0.016, that means 60 frames per second, so if you would like to achieve 10 meters per second instantly you would need a one time only addforce of 10 * 60 and the object will reach that speed immediately just like modifying velocity, the thing here is with this method is additive unlike directly modifying velocity.

    to make a body of any mass reach instantly 10 meters per second would be an addforce of (10 * 60) * mass all of this taking into account that you have a linear drag of 0

    once you implement drag, things get a little more complicated but thats a quick example

    theres a lot of information on the internet about physical forces that you can experiment with
     
    Last edited by a moderator: Nov 18, 2013
  5. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    5,041
    Although the gist of your post is fine, to conclude that they are mathematically identical seems a bit of a stretch. That would mean that Unity's implementation of Box2D is effectively the same code as Unity's implementation of PhysX when the 3rd dimension is removed, given there are many clearly different behaviours across these two libraries I find that hard to believe.
     
  6. Deleted User

    Deleted User

    Guest

    the forces are in newtons, a well stablished real world force unit, it doesnt matter how many dimensions are in the physics engine, it will always move a body of certain mass a certain distance in a certain time.. gravity and drag are just forces

    physics engines are programmed to mimic the basics of real world physics in this case simple newtonian rigid body physics, if a physics engine its designed to mimic newtons and the mks system, it will always perform accordingly, its one of the biggest selling points of mathematics , they are not subject to interpretation