Hi! Welcome to Unity and the forums
To make it easier for us to read your code, please properly insert it: Using code tags properly
You’re showing good effort but it’s too much. It’s really this simple:
using UnityEngine;
public class TestFPS : MonoBehaviour {
#region "Variables"
public Rigidbody Rigid;
public float MouseSensitivity;
public float MoveSpeed;
public float JumpForce;
#endregion
void Update ()
{
Rigid.MoveRotation(Rigid.rotation * Quaternion.Euler(new Vector3(0, Input.GetAxis("Mouse X") * MouseSensitivity, 0)));
Rigid.MovePosition(transform.position + (transform.forward * Input.GetAxis("Vertical") * MoveSpeed) + (transform.right * Input.GetAxis("Horizontal") * MoveSpeed));
if (Input.GetKeyDown("space"))
Rigid.AddForce(transform.up * JumpForce);
}
}
The jumping is there as an example; you’ll need to have a system to prevent infinite jump height from many key presses if you want jumping.
Also, check out the FPS controller in the Standard Assets!