How to set the "centre of gravity" of an object

edited September 2013 in Help request
:( :(

Comments

  • edited September 2013
    It's set by the density of the parts of the object.

    What are you trying to do?
    If you are using applyForce, in my experience sometimes it is easier to pass the center of the object (remember to use world coordinates, not the object's) or use setSpeed instead.
  • edited September 2013
    thx

    what I am trying to do is, when the object falling with physics
    a part of an object will be more heavy, and easy to touch the ground firstly

    for example,
    my object is a human, and he is waring a pair of very heavy boots
    and the boots will touch the ground first when he fell to the ground.

    sorry my english is bad. hope you can read it
  • edited September 2013
    I had the same problem some time ago, what I did was use:
    orxVECTOR force;
        orxObject_GetSpeed(arrow, &force);
        orxObject_SetRotation(arrow, normalizedRadians(orxMath_ATan(force.fY, force.fX)));
    

    This won't be physically perfect, but will work.

    The arrow is an arrow shot by the player, the head is always pointing to the resulting strenght.
    You will have to do some tests to find what final rotation you want.

    The normalizedRadians function is used to keep the angles between 0 and 2pi:
    static float normalizedRadians(orxFLOAT angle){
        if (angle > 0){
            while (angle >= orxMATH_KF_2_PI) angle -= orxMATH_KF_2_PI;
        }
        else{
            while (angle < 0) angle += orxMATH_KF_2_PI;
        }
    
        return angle;
    }
    

    In the original topic there are a few links to posts of people that got it done using box2d, you can find the original post here:
    https://forum.orx-project.org/discussion/6390

    If you are a native portuguese speaker, I can try to explain it to you in portuguese too.
  • edited September 2013
    Hey Knolan, thx for your help. I can fix it now.

    btw I am from Hong Kong.
Sign In or Register to comment.