Physics torque issue rotating towards a point

Get help using Construct 2

Post » Wed Jan 07, 2015 8:48 am

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!
You do not have the required permissions to view the files attached to this post.
B
5
S
2
Posts: 5
Reputation: 675

Post » Wed Jan 07, 2015 9:16 am

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 :)
B
48
S
16
G
9
Posts: 1,097
Reputation: 11,195

Post » Wed Jan 07, 2015 9:21 am

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.
B
5
S
2
Posts: 5
Reputation: 675

Post » Wed Jan 07, 2015 8:47 pm

I've done that before without the physics behavior here:
viewtopic.php?f=147&t=74386&p=620027&hilit=turret2#p620027

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.
viewtopic.php?f=146&t=113463&p=821290&hilit=mass#p821290
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.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Wed Jan 07, 2015 8:57 pm

@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.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,153

Post » Wed Jan 07, 2015 9:40 pm

Ok, here's two examples, one using the physics behavior and one using the chipmunk behavior
You do not have the required permissions to view the files attached to this post.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959


Return to How do I....?

Who is online

Users browsing this forum: lordsas, mekonbekon and 63 guests