MouseAround.Update () (at Assets/MouseAround.cs:20)
Синтаксис:
Используется csharp
using UnityEngine;
using UnityEngine.InputSystem;
public class MouseAround : MonoBehaviour
{
public float mouseSensevity = 100f;
public Transform playerBody;
float xRotation;
void Start()
{
}
void Update()
{
float mouseX = 0;
float mouseY = 0;
if(Touchscreen.current.touches.Count > 0 && Touchscreen.current.touches[0].isInProgress)
{
mouseX = Touchscreen.current.touches[0].delta.ReadValue().x;
mouseY = Touchscreen.current.touches[0].delta.ReadValue().y;
}
mouseX *= mouseSensevity;
mouseY *= mouseSensevity;
xRotation -= mouseY * Time.deltaTime;
xRotation = Mathf.Clamp(xRotation, -80, 80);
transform.localRotation = Quaternion.Euler(xRotation, 0, 0);
playerBody.Rotate(Vector3.up * mouseX * Time.deltaTime);
}
}
using UnityEngine.InputSystem;
public class MouseAround : MonoBehaviour
{
public float mouseSensevity = 100f;
public Transform playerBody;
float xRotation;
void Start()
{
}
void Update()
{
float mouseX = 0;
float mouseY = 0;
if(Touchscreen.current.touches.Count > 0 && Touchscreen.current.touches[0].isInProgress)
{
mouseX = Touchscreen.current.touches[0].delta.ReadValue().x;
mouseY = Touchscreen.current.touches[0].delta.ReadValue().y;
}
mouseX *= mouseSensevity;
mouseY *= mouseSensevity;
xRotation -= mouseY * Time.deltaTime;
xRotation = Mathf.Clamp(xRotation, -80, 80);
transform.localRotation = Quaternion.Euler(xRotation, 0, 0);
playerBody.Rotate(Vector3.up * mouseX * Time.deltaTime);
}
}