As the title suggests I'm developing a top down space game.
I'm not looking to use newtonian physics with the player controlled ship. I'm trying to achieve a control scheme somewhat similar to that of FlatSpace 2 (awesome game). I can't figure out how to achieve this feeling with keyboard controls as opposed to mouse controls though. Any suggestions?
I'm using Unity3d and C# or javaScript (unityScript or whatever is the correct term) works fine if you want to drop some code examples.
Edit: Of course I should describe FlatSpace 2's control scheme, sorry. You hold the mouse button down and move the mouse in the direction you want the ship to move in. But it's not the controls I don't know how to do but rather the feeling of a mix of driving a car and flying an aircraft. It's really well made. Youtube link: FlatSpace2 on iPhone
I'm not developing an iPhone game but the video shows the principle of the movement style.
Edit 2
As there seems to be a slight interest, I'll post the version of the code I've used to continue. It works good enough. Sometimes good enough is sufficient!
using UnityEngine;
using System.Collections;
public class ShipMovement : MonoBehaviour
{
public float directionModifier;
float shipRotationAngle;
public float shipRotationSpeed = 0;
public double thrustModifier;
public double accelerationModifier;
public double shipBaseAcceleration = 0;
public Vector2 directionVector;
public Vector2 accelerationVector = new Vector2(0,0);
public Vector2 frictionVector = new Vector2(0,0);
public int shipFriction = 0;
public Vector2 shipSpeedVector;
public Vector2 shipPositionVector;
public Vector2 speedCap = new Vector2(0,0);
void Update()
{
directionModifier = -Input.GetAxis("Horizontal");
shipRotationAngle += ( shipRotationSpeed * directionModifier ) * Time.deltaTime;
thrustModifier = Input.GetAxis("Vertical");
accelerationModifier = ( ( shipBaseAcceleration * thrustModifier ) ) * Time.deltaTime;
directionVector = new Vector2( Mathf.Cos(shipRotationAngle ), Mathf.Sin(shipRotationAngle) );
//accelerationVector = Vector2(directionVector.x * System.Convert.ToDouble(accelerationModifier), directionVector.y * System.Convert.ToDouble(accelerationModifier));
accelerationVector.x = directionVector.x * (float)accelerationModifier;
accelerationVector.y = directionVector.y * (float)accelerationModifier;
// Set friction based on how "floaty" controls you want
shipSpeedVector.x *= 0.9f; //Use a variable here
shipSpeedVector.y *= 0.9f; //<-- as well
shipSpeedVector += accelerationVector;
shipPositionVector += shipSpeedVector;
gameObject.transform.position = new Vector3(shipPositionVector.x, 0, shipPositionVector.y);
}
}