почему неработает "Cursor.lockState = CursorLockMode.Locked;"
использую Cursor.lockState = CursorLockMode.Locked; для вращения игрока, но курсор не возвращается в центр, незнаю что с этим делать, вот код (использую Photon для Мультиплеера)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
public class Move : MonoBehaviour
{
public PhotonView view;
public Vector2 cur;
// Start is called before the first frame update
void Start()
{
view = GetComponent<PhotonView>();
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
Cursor.lockState = CursorLockMode.Locked;
if(view.IsMine)
{
if(Input.GetKey(KeyCode.W))
{
transform.Translate(Vector3.forward * 5 * Time.deltaTime);
}
if (Input.GetKey(KeyCode.S))
{
transform.Translate(Vector3.back * 5 * Time.deltaTime);
}
if (Input.GetKey(KeyCode.A))
{
transform.Translate(Vector3.left * 5 * Time.deltaTime);
}
if (Input.GetKey(KeyCode.D))
{
transform.Translate(Vector3.right * 5 * Time.deltaTime);
}
Cursor.lockState = CursorLockMode.Locked;
cur = Input.mousePosition;
this.transform.eulerAngles = new Vector3(this.transform.rotation.x +(-Input.mousePosition.y / 30), this.transform.rotation.x + (Input.mousePosition.x /30), 0);
}
}
}
Источник: Stack Overflow на русском