Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class FirstPersonScript : MonoBehaviour {
- //PublicVariables //PublicDeclerations
- public float MouseSensitivity = 7.0f;
- public float zMovementspeed = 8.0f;
- public float xMovementspeed = 9.0f;
- public float PovRange = 110.0f;
- public float RotationY = 0;
- void Start () {
- Screen.lockCursor = true;
- }
- // Update is called once per frame
- void Update () {
- //Rotation
- //Variables // Declerations
- float RotationX = Input.GetAxis ("Mouse X") * MouseSensitivity;
- //Callback
- transform.Rotate (0, RotationX, 0);
- RotationY -= Input.GetAxis ("Mouse Y") * MouseSensitivity;
- RotationY = Mathf.Clamp (RotationY, -PovRange, PovRange);
- Camera.main.transform.localRotation = Quaternion.Euler (RotationY, 0, 0);
- //Movement
- //Variables // Declerations
- float zAxispeed = Input.GetAxis ("Vertical") * zMovementspeed;
- float xAxispeed = Input.GetAxis ("Horizontal") * xMovementspeed;
- Vector3 zSpeed = new Vector3 (xAxispeed, 0, zAxispeed);
- CharacterController CharControl = GetComponent<CharacterController>();
- //Callback
- zSpeed = transform.rotation * zSpeed;
- CharControl.SimpleMove( zSpeed );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement