Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question what am i doing wrong? error CS1503: Argument 1: cannot convert from 'float' to 'int'

Discussion in 'Scripting' started by sadi1, Oct 19, 2020.

  1. sadi1

    sadi1

    Joined:
    Sep 16, 2020
    Posts:
    15
    void FixedUpdate()
    {
    if (Path == null)
    return;

    if (currentWaypoint >= Path.vectorPath.Count)
    {
    reachedEndOfPath = true;
    return;
    }
    else
    {
    reachedEndOfPath = false;
    }

    Vector2 direction = ((Vector2)Path.vectorPath[currentWaypoint] - rb.position).rormalized;
    Vector2 force = direction * speed * Time.deltaTime;

    rb.AddForce(force);

    float distance = Vector2.Distance(rb.position, Path.vectorPath[currentWaypoint]);

    if (distance < nextWaypointDistance)
    {
    currentWaypoint++;
    }

    }
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605