Hello! I am getting an error when initializing the Vector 3 targetPosition in the code below.
This is the error code:
Here is the error:
Error CS0104 ‘Vector3’ is an ambiguous reference between ‘System.Numerics.Vector3’ and ‘UnityEngine.Vector3’
Here is my code:
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using UnityEngine;
public class Enemy : MonoBehaviour
{
[SerializeField]
private Transform[ ] waypoints;
private Vector3 targetPosition;
// Use this for initialization
void Start()
{
targetPosition = waypoints[0].position;
}
// Update is called once per frame
void Update()
{
Class definitions can have the same name while being in different namespaces. There is a definition for Vector3 in System.Numerics and there is one in UnityEngine. Since you use both of these namespaces in this code via using directives, it gets confused what it should use.
Either remove using System.Numerics;, which doesn’t appear to be used in the code, or add the following line under your using directives: