Roots
Мудрец
(13729)
6 месяцев назад
Щас, подожди, запущу компилятор у себя в голове, скомпилирую и скажу, какую ошибку вывело
Серьёзно, на что вы надеетесь, говоря о том, что есть ошибка, но не называя саму ошибку?
Миша КалакутскийЗнаток (312)
6 месяцев назад
Ошибка CS0104 "Vector3" является неоднозначной ссылкой между "UnityEngine.Vector3" и "System.Numerics.Vector3". Assembly-CSharp D:\Projects\My project\Assets\First person\PlayerMovement.cs 20 Активные
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using UnityEngine;
namespace Player
{
public class PlayerMovement : MonoBehaviour
{
[SerializeField] private float _walkspeed = 5;
[SerializeField] private float _runspeed = 8;
[SerializeField] private float _rotateSpeed = 75;
private CharacterController _characterController;
private Camera _playerCamera;
private Vector3 _velocity;
private Vector2 _rotation;
private Vector2 _direction;
// Start is called before the first frame update
void Start()
{
_playerCamera = GetComponentInChildren<Camera>();
Cursor.lockState = CursorLockMode.Locked;
}
// Update is called once per frame
void Update()
{
_characterController.Move(motion:_velocity * Time.deltaTime);
_direction = new Vector2(x: Input.GetAxis("Horizontal"), y: Input.GetAxis("Vertical"));
Vector2 mouseDelta = new Vector2(x: Input.GetAxis("Mouse X"), y: Input.GetAxis("Mouse Y"));
mouseDelta *= _rotateSpeed * Time.deltaTime;
_rotation.y += mouseDelta.x;
_rotation.x = Mathf.Clamp(value: _rotation.x - mouseDelta.y, min: -90, max: 90);
_playerCamera.transform.localEulerAngles = (Vector3)_rotation;
}
private void FixedUpdate()
{
_direction *= Input.GetKey(KeyCode.LeftShift) ? _runspeed : _walkspeed;
Vector3 move = Quaternion.Euler(x: 0, _playerCamera.transform.eulerAngles.y, z: 0) * new Vector3(_direction.x, y: 0, z: _direction);
_velocity = new Vector3(move.x, _velocity.y, move.z);
}
}
}