How do you vibrate or cause a shake effect to a body of type static or dynamic or kinematic. I tried applying forces to a dynamic body in the timeStep, which did not work, as well I tried ApplyLinearImpulse many times a sec within the timeStep, which again did not give me the result. So right now Iam experimenting with adding a static circle body as a hinge point to my rectangular body and create a revolute joint between them. May be then applying a force could result in Tension between the 2 bodies? Does anybody know about this? have any ideas please let me know?
1 Answer
\$\begingroup\$
\$\endgroup\$
okay I just figured everything out...all I had to do was to set the linearVeolcity using boolean logic. i.e
if(counter <50)
{
if(toggle)
{
body->setLinearVelocity(5.0,0.0)
}
else
{
body->SetLinearVelocity(-5.0,0.0)
}
toggle = !toggle
}
counter++;
if(counter>50)
{
break away from being static body
}
all of the above code has to go in to the timeStep under the loop in which you iterate the b2Bodies of the world.....the logic is simple.
body->getFixture()
gives you access to body's first fixture, for the next fixtures callfixture->nextfixture()
. and fixtures have setposition function that you can use to change their positions \$\endgroup\$