using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Runtime;
using UnityEngine;
public class swordrotation : MonoBehaviour
{
public float mouseSensitivity = 100f;
public Transform SwordRotation;
float xRotation = 0f;
float zRotation = 0f;
// Start is called before the first frame update
void Start()
{
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
if (Input.GetMouseButton(0))
{
float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;
xRotation = Mathf.Clamp(xRotation, -40, 60);
zRotation = Mathf.Clamp(zRotation, -90, 90);
SwordRotation.Rotate(new Vector3(10f, 0f, 0f) * mouseY);
SwordRotation.Rotate(new Vector3(0f, 0f, 10f) * mouseX);
}
}
}