2
\$\begingroup\$

I have got a floating character, which should be a robot like thing, floating over the ground, whereby I am using the »hovercar« effect described here. Zhe Image below outlines the basic setup of the physics

enter image description here

The Green rectangle is the chassis, its not allowed to rotate and held up by the »hover-power«. Attached to this is the robots head with an revolute joint, and attached to the head is the robots body, with another revolute joint. There are some more distance Joints for damping this, but not of interest for now.

In the next image one can see how the body of the robot should be tilted when it is in motion to the right or left.

enter image description here

Right now, the movement of the character is implemented so that forces and impulses are applied to the chassis body. Especially if there is an Impulse to the left or right, the desired tilt of the robots body comes to happen, but it fades away when the velocity becomes more constant, or acceleration comes closer to zero.

What can I do to keep the robots body tilted, when it is in motion?

\$\endgroup\$
  • 1
    \$\begingroup\$ Apply a light force to the bottom of the object in the opposite direction? \$\endgroup\$ – ClassicThunder Mar 31 '14 at 21:04
  • \$\begingroup\$ Yes, that's probably a good Idea, but I am looking for a more »code less« way, just using joints, damping or something like that—something box2d brings »out of the box«. My tests with linear damping just slowed down the whole character, so I am searching for an alternative way… \$\endgroup\$ – philipp Apr 1 '14 at 11:09
  • \$\begingroup\$ Applying forces are pretty much what Box2D is built around. \$\endgroup\$ – ClassicThunder Apr 1 '14 at 13:27
  • \$\begingroup\$ Yes, that is absolutely true, but applying the force needs to be triggered by code. Would be fine if there would be a solution which can be modeled within RUBE. \$\endgroup\$ – philipp Apr 1 '14 at 14:13
  • \$\begingroup\$ You can set the LinearDamping property of the body, then it will automatically apply forces that resist motion. \$\endgroup\$ – mklingen Jan 2 '15 at 2:39
1
\$\begingroup\$

The move of the body is due to the air resistance.
You should apply a -k*v force to the lower part of the body.
Or even more accurate : project the speed vector on the frontmost line of the body : you now have Speed = (sx',sy'). Now apply two different coefficient, k1 and k2, for sx' and sy'. k1 would be the coefficient induced by some air coming face to the body, and k2 is the coefficient when the air comes from below the body (like 8 times smaller).
This way you'll have a realistic behavior : when going up the robot will be aligned, and the effect when going right or left will be the one you seek.

enter image description here

F = -k1 * sx ' * U - k2 * sy' *  V  
Or : 
F = - k1 * ( S • U ) * U - k2 * ( S • V) * V
\$\endgroup\$
-1
\$\begingroup\$

Why dont you apply force during the render thread. You can set a boolean value start and stop the tilt, since its under the render thread it will probably stay tilted since that same force is being applied constantly

\$\endgroup\$
  • \$\begingroup\$ It is a very bad idea to do physics in rendering thread. It breaks the whole encapsulation thing... \$\endgroup\$ – akaltar Apr 2 '15 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.