Search Unity

How do I get the get normal constraining force of game object

Discussion in 'Physics' started by Cheneyqgx, Jul 19, 2021.

  1. Cheneyqgx

    Cheneyqgx

    Joined:
    Jul 8, 2021
    Posts:
    2

    I am making a simulation of physics for high school students,but i dont know how to get these supporting force, like the N force in the picture,could you help me?Thanks a lot
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
    You don't explain what you mean by "get these" and don't say if this is 2D or 3D physics. You certainly don't go to an object and ask it for these discrete components because they're not stored like that.

    G is the global gravity (2D or 3D), F is the force you're applying so only you'll know that (unless you're referring to surface friction) and N is the collision normal which you get when reading the contacts, the contacts provided by the physics callbacks or from explicitly queries you perform.
     
  3. Cheneyqgx

    Cheneyqgx

    Joined:
    Jul 8, 2021
    Posts:
    2
    Thank you very much,i am sorry i did not say it clearly,it is a 2D physics.Your answer will Solving the direction of
    normal constraining force,but how about magnitude?Like in the picture N=Gcosθ,but in other situation(with acceleration)it will change.So is there a easy way to get that?Thank you very much again
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,481
    The 2D physics engine supplies you with contact points (either you asking for them or during collision callbacks). If you look at the API docs for a ContactPoint2D you'll see it includes impulses applied along a contact Normal (separation) and contact Tangent (friction). There can be multiple contacts on a surface.

    If you need more detail on what is going on, know that we use a pretty much stock Box2D which you can find on Github here. It may serve as a useful reference or guide for further information on where these impulses come from etc.