Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CameraScript : MonoBehaviour
- {
- [SerializeField] private Transform CameraTransform;
- public float mouseSencitivity = 100f;
- public Transform playerBody;
- public Transform playerBody1;
- float xRotation = 0f;
- void Update()
- {
- float mouseX = Input.GetAxis("Mouse X") * mouseSencitivity * Time.deltaTime;
- float mouseY = Input.GetAxis("Mouse Y") * mouseSencitivity * Time.deltaTime;
- xRotation -= mouseY;
- xRotation = Mathf.Clamp(xRotation, -90f, 90f);
- transform.localRotation = Quaternion.Euler(xRotation, -90, 0);
- playerBody.Rotate(Vector3.up * mouseX);
- playerBody1.Rotate(Vector3.up * mouseX);
- this.transform.position = playerBody.position;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement