Skip to main content

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 }

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.

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.

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.

Source Link

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.