Ошибка 'Vector2' is an ambiguous reference between 'UnityEngine.Vector2' and 'System.Numerics.Vector2'
Assets/Scripts/New_wall.cs(10,5): error CS0104: 'Vector2' is an ambiguous reference between 'UnityEngine.Vector2' and 'System.Numerics.Vector2' помогите
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using UnityEngine;
public class New_wall : MonoBehaviour
{
public float speed = 8f;
Vector2 direction;
Rigidbody2D rigidbody;
// Start is called before the first frame update
void Start()
{
rigidbody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
{
direction = Vector2.up;
}
else if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
{
direction = Vector2.down;
}
else
{
direction = Vector2.zero;
}
if (direction.x * direction.x + direction.y * direction.y != 0)
{
rigidbody.AddForce(direction * speed);
}
}
}
Ответы (1 шт):
Автор решения: Qwer
→ Ссылка
Дело в том, что у тебя подключено два пространства имён: System.Numerics и UnityEngine. В каждом из них есть Vector2, и компилятор не знает какой ты хочешь использовать.
На будущее, если компилятор выдаёт ошибку, прежде чем писать на форум, её нужно загуглить. У тебя это CS0104, просто вводишь в поиск C# CS0104 и скорее всего найдёшь ответ в чём проблема.