Пример #1
0
void Racer::reset()
{
	hkVector4 reset = hkVector4(0.0f, 0.0f, 0.0f);
	setPosAndRot(0.0f, 10.0f, 0.0f, 0, 0, 0);
	body->setLinearVelocity(reset);
	wheelFL->body->setLinearVelocity(reset);
	wheelFR->body->setLinearVelocity(reset);
	wheelRL->body->setLinearVelocity(reset);
	wheelRR->body->setLinearVelocity(reset);
}
Пример #2
0
void Racer::reset(hkVector4* resetPos, float rotation)
{
	hkVector4 reset;
	reset.set(0.0f, 0.0f, 0.0f);

	hkVector4 resetPosition;
	resetPosition.setXYZ(*resetPos);

	// Generate random offsets so that the racer doesn't spawn exactly in the middle of the track anymore.
	srand((unsigned)time(0)+givenDamage);
	int offsetX = rand()%5;
	srand((unsigned)time(0)+offsetX);
	int offsetZ = rand()%5;
	if(offsetX%2 == 0){
		offsetX *= -1;
	}
	if(offsetZ%2 == 0){
		offsetZ *= -1;
	}


	//------------------------

	setPosAndRot(resetPosition(0)+offsetX, resetPosition(1), resetPosition(2)+offsetZ, 0, rotation, 0);
	body->setLinearVelocity(reset);
	wheelFL->body->setLinearVelocity(reset);
	wheelFR->body->setLinearVelocity(reset);
	wheelRL->body->setLinearVelocity(reset);
	wheelRR->body->setLinearVelocity(reset);

	body->setAngularVelocity(reset);
	wheelFL->body->setAngularVelocity(reset);
	wheelFR->body->setAngularVelocity(reset);
	wheelRL->body->setAngularVelocity(reset);
	wheelRR->body->setAngularVelocity(reset);
}