I have a question I made a game where you controll an spacecraft and use the mouse/keyboard to move. I use the mouse to rotate the ship up, down left and right. Works like a charm. Only problem is when I stop moving the mouse the ship also stops. So If I want to rotate the ship a few times I need to run a marathon with my mouse. This is because I use the Input.Axis(Mouse X) and thats zero when you stop moving the mouse.
So what I want is: Rotate the ship lets say left if I move my mouse a bit to the left and only stop when I return the mouse to the centerarea. I have this code ATM
var c = Camera.main.transform;
float mouseX = Input.GetAxis("Mouse X");
c.Rotate(0, mouseX * sensitivity, 0);
c.Rotate(-Input.GetAxis("Mouse Y") * sensitivity, 0, 0);
c.Rotate(0, 0, -Input.GetAxis("QandE") * 90 * Time.deltaTime);
How can I accomplish this
BugFinder's answer is correct. Here it is in code, for rotating around the Y axis. You can build on it to get your other axes working.
using UnityEngine;
public class Roll : MonoBehaviour
{
public float sensitivity = .001f;
Transform c;
void Start()
{
c = Camera.main.transform;
}
void Update()
{
Vector3 mouse = Input.mousePosition;
float dx = 0;
if (mouse.x > 1000)
dx = mouse.x - 1000;
if (mouse.x < 920)
dx = mouse.x - 920;
c.Rotate(0, dx * sensitivity, 0);
}
}