Physics torque issue rotating towards a point

0 favourites
  • 6 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • I am having trouble figuring out how to make a physics object rotate directly towards a point without overshooting it and then coming back. When I apply a torque towards an angle even if I have the angular damping at maximum and set it to lower the torque applied as it closes in on the desired point it oscillates back and forth. On the box2d page here, (http://www.iforce2d.net/b2dtut/rotate-to-angle) it has an example at the end of the torque section but I cannot understand the code they have it written in. I am hopefully looking for a solution that would work for any object with any density. Thanks in advance for any help!

  • I would be inclined to say that this is a normal effect. Any body with mass rotating around a free pivot will exhibit this. I should imagine the only way to counter this would be to apply a suitable counter-touque. Unfortunately maths is not my strong point. R0J0hound would be the man to give a more definitive answer

  • Thanks for the quick reply. Yeah, I don't think its a bug, I just really suck at math and I cannot figure out when and how much counter-torque to make it come to a smooth stop on the first time.

  • I've done that before without the physics behavior here:

    It can be done with physics but the torque calculation needs the object's inertia

    torque = inertia*angularAcceleration.

    But for that you'll also need to manually calculate inertia from the object's mass since the behavior doesn't give it:

    inertia = mass * (width^2 + height^2)/12

    Also the units of the mass expression of the physics behavior is off.

    so to get a correct value you need to divide it by 50 to get a correct value.

    I forget if there are any other quirks that make it tricky. :/

    I'll try to get a example going over the next few days.

  • R0J0hound - as always, helpful as ever. I appreciate the help you have given me and others.

    dax - I got your pm, and I am glad my post was of use to you. I think R0j0Hound has it covered here though. I struggle with math as soon as it gets more complicated than hello world stuff- I get along simply because I get obsessed over it and spend 8 hours trying to figure out why stuff like x = l*sin(a) works.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok, here's two examples, one using the physics behavior and one using the chipmunk behavior

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)