using System.Runtime.CompilerServices;
using Unity.Mathematics;
using Unity.VisualScripting;
using UnityEngine;
using Vector3 = UnityEngine.Vector3;
public class Player : MonoBehaviour
{
[SerializeField] private float speed = 2f;
[SerializeField] private float turnspeed = 45f;
[SerializeField] private Transform CameraTransform;
private Animator animator;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
animator = GetComponent();
}
// Update is called once per frame
void Update()
{
float HorizontalInput = Input.GetAxis("Horizontal");
float VerticalInput = Input.GetAxis("Vertical");
var velocity = Vector3.forward * Input.GetAxis("Vertical")* speed;
transform.Translate(velocity * Time.deltaTime);
transform.Rotate(Vector3.up, Input.GetAxis("Horizontal")* Time.deltaTime * turnspeed);
animator.SetFloat("speed", velocity.magnitude);
Vector3 movement = new Vector3(HorizontalInput, 0 ,VerticalInput);
movement = quaternion.AxisAngle(CameraTransform.rotation.eulerAngles.y, Vector3.up)* movement;
}
private void OnApplicationFocus(bool focus)
{
if (focus)
{
Cursor.lockState = CursorLockMode.Locked;
}
}
}
Для изменения масштаба при блокировке камеры. не выполнять автоматическое масштабирование при перемещении курсора с помощью Cinemachine
Я пытаюсь заблокировать камеру, следуя этому руководству YT. [youtube]jiyOZbKRfaY[/youtube] но на линии движения =.... ошибка на Vector3 . чего я не понимаю. Кроме того, я все еще новичок в кодировании C# для Unity. спасибо за ответ! [code]using System.Runtime.CompilerServices; using Unity.Mathematics; using Unity.VisualScripting; using UnityEngine; using Vector3 = UnityEngine.Vector3;
public class Player : MonoBehaviour { [SerializeField] private float speed = 2f; [SerializeField] private float turnspeed = 45f; [SerializeField] private Transform CameraTransform; private Animator animator;
// Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { animator = GetComponent(); }
// Update is called once per frame void Update() { float HorizontalInput = Input.GetAxis("Horizontal"); float VerticalInput = Input.GetAxis("Vertical");
var velocity = Vector3.forward * Input.GetAxis("Vertical")* speed;