I am looking to make a spaceship tilt as it corners but I cant get it to return
- by bobthemac
I am using the TL game engine I am not allowed to use a physics engine but I need to make the spaceship lean as it corners, I can make it lean but cannot make it return to its starting position. I have looked at implementing some kind of spring physics but I don't understand it.
Here is my code so far
if(myEngine->KeyHeld(Key_A))
{
car->RotateY(carSteer * frameTime);
if(carSteer >= -carMaxSteer)
{
carSteer -= carSteerIncrement;
car->RotateLocalZ(-(carSteer * frameTime));
}
}
if(!myEngine->KeyHeld(Key_A))
{
if(carSteer < 0)
{
carSteer = 0;
}
}
if(myEngine->KeyHeld(Key_D))
{
car->RotateY(carSteer * frameTime);
if(carSteer <= carMaxSteer)
{
carSteer += carSteerIncrement;
car->RotateLocalZ(-(carSteer * frameTime));
}
}
if(!myEngine->KeyHeld(Key_D))
{
if(carSteer > 0)
{
carSteer = 0;
}
}
All the functions I am calling are built into the engine and I did not write them.
Any Help Would Be Appreciated Thanks.