So, as some of you might have noticed from previous posts I'm working on a space sim sort of game.
In the past I've moved to use BulletSharp for physics (mainly for collision ^^)
Now I want to get my mouse based steering to work.
Basically what I'm doing right now is (pseudocode):
InputSystem
{
GetMousePosition;
GetMouseOffsetFromScreenCenter(mousePosition);
CalculateTurnMultiplier(mouseOffset)
RotationComponent.turnMulti = turnMulti;
}
MovementSystem
{
torqueVector = (turnMulti*steeringTorque*scaling) transformed by rigidBody.Orientation
rigidBody.ApplyTorque(torqueVector);
}
This does turn the ship, but in all kinds of weird ways.
The steering behaviour I want is actually like this:
[attachment=31472:spaceshipturning.png]
Kind of like in freelancer.
Now, I've already figured out on how to get my desired TurnMultiplier (how hard the ship shall turn), but the calculation of the correct torque to put into BulletSharp is giving me headaches.
My theory is that, when I move the cursor away from the screen center I need to add more torque based on how fast I'm already turning and vice versa. But this just doesn't want to compute in my head.