Guest User

Untitled

a guest
Feb 5th, 2021
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CameraScript : MonoBehaviour
  5. {
  6. [SerializeField] private Transform CameraTransform;
  7. public float mouseSencitivity = 0f;
  8. public Transform playerBody;
  9. public Transform playerBody1;
  10. float xRotation = 0f;
  11. void Update()
  12. {
  13. float mouseX = Input.GetAxis("Mouse X") * mouseSencitivity * Time.deltaTime;
  14. float mouseY = Input.GetAxis("Mouse Y") * mouseSencitivity * Time.deltaTime;
  15. xRotation -= mouseY;
  16. xRotation = Mathf.Clamp(xRotation, -90f, 90f);
  17. transform.localRotation = Quaternion.Euler(xRotation, -90, 0);
  18. playerBody.Rotate(Vector3.up * mouseX);
  19. playerBody1.Rotate(Vector3.up * mouseX);
  20. this.CameraTransform.rotation = Quaternion.Euler(this.CameraTransform.rotation.x, this.CameraTransform.rotation.y - 90f, this.CameraTransform.rotation.z);
  21. }
  22. void Start()
  23. {
  24. StartCoroutine(TestCoroutine());
  25. }
  26. IEnumerator TestCoroutine()
  27. {
  28. yield return new WaitForSeconds(1f);
  29. mouseSencitivity = 100f;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment