I am looking to make a spaceship tilt as it corners but I cant get it to return

Posted by bobthemac on Game Development See other posts from Game Development or by bobthemac
Published on 2012-04-04T16:38:35Z Indexed on 2012/04/04 17:42 UTC
Read the original article Hit count: 206

Filed under:
|
|
|

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.

© Game Development or respective owner

Related posts about c++

Related posts about engine