I’ve been working on my game for a while without any interest in making it work with a controller, but by accident I discovered that the player could already use the controller, partially. I’ve been going through my scripts and changing the controls to the input buttons instead of accessing keys directly. Everything works with a controller now, except while holding left on the keyboard, the player rotates to the left as expected. On the controller, however, holding the analog stick left make the player rotate to the right, and vice versa. Here’s my movement script, it makes for some really smooth space ship movement.
public float accelerationForce = 10f;
public float rotationForce = 3f;
void MoveShip ()
{
float rotation = Input.GetAxis("Horizontal");
float acceleration = Input.GetAxis("Vertical");
GetComponent<Rigidbody>().AddTorque(0, 0, rotation * rotationForce * Time.deltaTime);
GetComponent<Rigidbody>().AddForce(transform.up * acceleration * (accelerationForce * Time.deltaTime));
}
I don’t know if it is relevant, but my game is 3D, set up as 2D. Like, all of the object in the game have 3D models, but the camera is orthographic and all the action takes place at 0 on the z axis.
EDIT: Also possibly relevant, accelerationForce and rotationForce have been set to 300 & 200, respectively, in the inspector.