I have am trying this code with default input manager settings. It is attached to a game object with no other components in scene. Its Camera field is setted to default camera in the scene. Each input function returns false/0 no matter what I try. Even Input.anyKeyDown never returns true.
public class KeyboardController : MonoBehaviour
{
public float YMin = -100;
public float YMax = 100;
public float XMin = -100;
public float XMax = -100;
public float XSpeed = 1;
public float YSpeed = 1;
public float MouseXSpeed = 1;
public float MouseYSpeed = 1;
public GameObject Camera;
public void Update()
{
var pos = Camera.transform.position;
var x = pos.x;
var y = pos.y;
if (Input.GetKeyDown(KeyCode.Mouse1))
{
x += MouseXSpeed * Time.deltaTime * Input.GetAxis("Mouse X");
y += MouseYSpeed * Time.deltaTime * Input.GetAxis("Mouse Y");
}
else
{
x += XSpeed * Time.deltaTime * Input.GetAxis("Horizontal");
y += YSpeed * Time.deltaTime * Input.GetAxis("Vertical");
}
if (x < XMin)
x = XMin;
else if (x > XMax)
x = XMax;
if (y < YMin)
y = YMin;
else if (y > YMax)
y = YMax;
Camera.transform.position.Set(x, y, pos.z);
}
}