I have been attempting to move an object that I have control over in the forward direction, which I can do just fine, but as soon as I would like to implement having the ability to turn it seems as if any attempt I make can't seem to make the object turn properly. What always ends up happening is it starts to turn, then kind of just turns in on its self and goes into an unpredictable direction. What I would like to do so if I pressed my forward key, and held my right turn key at the same time, it would move in a circle.
What I have tried is the following
Moving Forward (works fine, when I don't do any sort of a turn). _13, _23 and _33 is my forward vector for my matrix.
float x = transform->getLocalTransform()._13 * (fowardmovement * elapsedtime);
float y = transform->getLocalTransform()._23 * (fowardmovement * elapsedtime);
float z = transform->getLocalTransform()._33 * (fowardmovement * elapsedtime);
// apply the movement as an impulse to the rigid body for the object
objectrigidbody->addImpulseForce(x, y, z);
I do the same thing for going backwards, but with a backwardmovement variable.
What I have tried to do for turning is just applying a rotation directly on the Y for the object.
// the function rotate applies the rotation directly to the object, with no return value
objectrigidbody->rotate(0.0, turnmovement * elapsedtime, 0.0);
Would anyone happen to know how I can get my object to be able to as if it was moving in a circle if I were to hold my forward and right turn key?