Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Vector 2 is an ambiguous reference error

Discussion in 'Scripting' started by Brownie32, Aug 17, 2022.

  1. Brownie32

    Brownie32

    Joined:
    Aug 13, 2022
    Posts:
    5
    This error keeps showing: "'(23,53)Vector 2' is an ambiguous refrence between 'UnityEngine.Vector2' and 'System.numerics.Vector2'
    here is my code:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using Vector3 = UnityEngine.Vector3;
    public class PlayerMotor : MonoBehaviour
    {
    private CharacterController controller;
    private Vector3 playerVelocity;
    public float speed = 5f;
    // Start is called before the first frame update
    void Start()
    {
    controller = GetComponent<CharacterController>();
    }
    // Update is called once per frame
    void Update()
    {
    }
    //recive the inputs for our InputManager.cs and apply them to our character
    public void ProcessMove(Vector2 input)
    {
    Vector3 moveDirection = Vector3.zero;
    moveDirection.x = input.x;
    moveDirection.z = input.y;
    controller.Move(transform.TransformDirection(moveDirection) * speed * Time.deltaTime);
    }
    }
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,735
    Sounds like you have
    Code (CSharp):
    1. using System.Numerics;
    Somewhere in your code (although it is not in what you shared?) Deleting that line will make the error go away. You should also be able to delete
    using Vector3 = UnityEngine.Vector3;
    when you do that.

    It's also possible you have:
    Code (CSharp):
    1. global using System.Numerics;
    in another script entirely. If that's the case finding and deleting that line should solve your problem for all files in your project.
     
  3. Brownie32

    Brownie32

    Joined:
    Aug 13, 2022
    Posts:
    5
    okay! thank you that helped me alot
     
    PraetorBlue likes this.