Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Vector2 problem

Guys I have a problem,

I try to make o line of code, but this error

CS0104 'Vector2' is an ambiguous reference between 'System.Numerics.Vector2' and 'UnityEngine.Vector2'

PLS HELP ME!!!!!


This is the line of code:

{

  public float speed;

  private Rigidbody2D rb;

  private Vector2 move_velocity;


  void Start()

  {

    rb = GetComponent<Rigidbody2D>();

  }


  void Update()

  {

    Vector2 move_input = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));

    move_velocity = move_input * speed;

  }


  void FixedUpdate()

  {

    rb.MovePosition(rb.position + move_velocity * Time.deltaTime);

  }

}

Best Answer

  • Sl0thSl0th Member
    Accepted Answer

    Hey, I believe this is because you are using two different namespaces that both define a Vector2.

    The solution is probably to either stop using System.Numerics, be more specific with your import ("using System.Numerics.X"), or writing "UnityEngine.Vector2" every time you define a Vector2 object .

    Hope this helps.

Answers

  • MrSlugMrSlug Member

    Sl0th is absolutely correct, this seems to be an irritating auto import that Visual Studio does.

    Had the same issue with Vector3

  • WarpWarp Member

    @SI0th +1

  • PredomPredom Member

    thanks

    Sorry for my English

Sign In or Register to comment.