I am try make simple flying camera. Without character. But than I press forward camera moving to another direction.
void Update()
{
horizontalInput = Input.GetAxisRaw("Horizontal");
verticalInput = Input.GetAxisRaw("Vertical");
var mouseX = Input.GetAxis("Mouse X");
var mouseY = Input.GetAxis("Mouse Y");
var trm = Camera.main.transform;
if (horizontalInput != 0 || verticalInput != 0)
{
trm.position += moveSpeed * new Vector3(horizontalInput, 0, verticalInput);
}
var rotateValue = new Vector3(mouseY * 2, mouseX * -2, 0);
trm.eulerAngles -= rotateValue;
//trm.rotation = Quaternion.Euler(rotateValue);
}
Than I press 'W' camera moving to left... I understand that it is necessary to coordinate the motion vectors and camera rotation. How best to do it?