Hello,
i make game about locomotive. I created ground box and small polygones, they are coals, i need move up and down my ground box with some frequency which a calculate with cos. But when i change Y axe value some coals falls some stay in their places so it seems to that physics goes crazy.
this is my code:
// locomotive shaking
teVector3df locomotivePosition = locomotive->GetPosition();
teVector3df stockerPosition = stoker->GetPosition();
b2Vec2 groundBoxPosition = groundBody->GetPosition();
float angSpeedShaking = (V_current-1) / 2 * tePi * 15.f;
angShaking = angShaking + angSpeedShaking * dt;
float amplitude = V_current * 2.f * teCos(angShaking * teDegToRad) * dt;
locomotivePosition.Y = LOCOMOTIVE_Y_POSITION + amplitude;
stockerPosition.Y = STOCKER_Y_POSITION + amplitude;
groundBoxPosition.y = groundBody_y_position + amplitude;
groundBody->SetTransform(groundBoxPosition, 0.f);
stoker->SetPosition(stockerPosition);
locomotive->SetPosition(locomotivePosition);
printf ("amplituda = %0.3f\n", groundBody_y_position);
I use some engine developed in my company so there is a mix of code.
i make game about locomotive. I created ground box and small polygones, they are coals, i need move up and down my ground box with some frequency which a calculate with cos. But when i change Y axe value some coals falls some stay in their places so it seems to that physics goes crazy.
this is my code:
// locomotive shaking
teVector3df locomotivePosition = locomotive->GetPosition();
teVector3df stockerPosition = stoker->GetPosition();
b2Vec2 groundBoxPosition = groundBody->GetPosition();
float angSpeedShaking = (V_current-1) / 2 * tePi * 15.f;
angShaking = angShaking + angSpeedShaking * dt;
float amplitude = V_current * 2.f * teCos(angShaking * teDegToRad) * dt;
locomotivePosition.Y = LOCOMOTIVE_Y_POSITION + amplitude;
stockerPosition.Y = STOCKER_Y_POSITION + amplitude;
groundBoxPosition.y = groundBody_y_position + amplitude;
groundBody->SetTransform(groundBoxPosition, 0.f);
stoker->SetPosition(stockerPosition);
locomotive->SetPosition(locomotivePosition);
printf ("amplituda = %0.3f\n", groundBody_y_position);
I use some engine developed in my company so there is a mix of code.