Advertisement
Guest User

Untitled

a guest
Feb 5th, 2021
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 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 = 100f;
  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.transform.position = playerBody.position;
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement