Hi,
if(leftWheelRevoluteJoint)
{
leftWheelRevoluteJoint.SetMotorSpeed(50*Math.PI * (kbd.isKeyPressed(40) ? 1 : kbd.isKeyPressed(38) ? -1 : 0));
leftWheelRevoluteJoint.SetMaxMotorTorque(kbd.isKeyPressed(40) || kbd.isKeyPressed(38) ? 30 : 0);
}
if(rightWheelRevoluteJoint)
{
rightWheelRevoluteJoint.SetMotorSpeed(50*Math.PI * (kbd.isKeyPressed(40) ? 1 : kbd.isKeyPressed(38) ? -1 : 0));
rightWheelRevoluteJoint.SetMaxMotorTorque(kbd.isKeyPressed(40) || kbd.isKeyPressed(38) ? 25 : 0);
}
if(leftAxlePrismaticJoint)
{
leftAxlePrismaticJoint.SetMaxMotorForce(30+Math.abs(800*Math.pow(leftAxlePrismaticJoint.GetJointTranslation(), 2)));
leftAxlePrismaticJoint.SetMotorSpeed(-50*Math.pow(leftAxlePrismaticJoint.GetJointTranslation(), 1));
}
if(rightAxlePrismaticJoint)
{
rightAxlePrismaticJoint.SetMaxMotorForce(30+Math.abs(800*Math.pow(rightAxlePrismaticJoint.GetJointTranslation(), 2)));
rightAxlePrismaticJoint.SetMotorSpeed(-50*Math.pow(rightAxlePrismaticJoint.GetJointTranslation(), 1));
}
carBody.ApplyTorque(40*(kbd.isKeyPressed(37) ? -1: kbd.isKeyPressed(39) ? 1 : 0));
This is the code i'm using for bike movement by pressing the left and right arrow.
if i'm not pressing any key, the bike movement is still there for more then five seconds. But i want the bike should stop immediately.
so that i checked the revolutejoint motor speed and it shows zero. But the revolutejoint joint speed is not zero.
like this i have checked for joint speed(trace(leftWheelRevoluteJoint.GetJointSpeed())).
how can i get rid of this?
if(leftWheelRevoluteJoint)
{
leftWheelRevoluteJoint.SetMotorSpeed(50*Math.PI * (kbd.isKeyPressed(40) ? 1 : kbd.isKeyPressed(38) ? -1 : 0));
leftWheelRevoluteJoint.SetMaxMotorTorque(kbd.isKeyPressed(40) || kbd.isKeyPressed(38) ? 30 : 0);
}
if(rightWheelRevoluteJoint)
{
rightWheelRevoluteJoint.SetMotorSpeed(50*Math.PI * (kbd.isKeyPressed(40) ? 1 : kbd.isKeyPressed(38) ? -1 : 0));
rightWheelRevoluteJoint.SetMaxMotorTorque(kbd.isKeyPressed(40) || kbd.isKeyPressed(38) ? 25 : 0);
}
if(leftAxlePrismaticJoint)
{
leftAxlePrismaticJoint.SetMaxMotorForce(30+Math.abs(800*Math.pow(leftAxlePrismaticJoint.GetJointTranslation(), 2)));
leftAxlePrismaticJoint.SetMotorSpeed(-50*Math.pow(leftAxlePrismaticJoint.GetJointTranslation(), 1));
}
if(rightAxlePrismaticJoint)
{
rightAxlePrismaticJoint.SetMaxMotorForce(30+Math.abs(800*Math.pow(rightAxlePrismaticJoint.GetJointTranslation(), 2)));
rightAxlePrismaticJoint.SetMotorSpeed(-50*Math.pow(rightAxlePrismaticJoint.GetJointTranslation(), 1));
}
carBody.ApplyTorque(40*(kbd.isKeyPressed(37) ? -1: kbd.isKeyPressed(39) ? 1 : 0));
This is the code i'm using for bike movement by pressing the left and right arrow.
if i'm not pressing any key, the bike movement is still there for more then five seconds. But i want the bike should stop immediately.
so that i checked the revolutejoint motor speed and it shows zero. But the revolutejoint joint speed is not zero.
like this i have checked for joint speed(trace(leftWheelRevoluteJoint.GetJointSpeed())).
how can i get rid of this?