Assets\enemy_AI.cs(55,55): error CS1503: Argument 1: cannot convert from 'float' to 'int'

hi this is the full code from my last post, please bare with me since im new to this and only started learning about a week ago

using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Threading;
using Pathfinding;
using UnityEngine;

public class enemy_AI : MonoBehaviour
{

    public Transform target;

    public float speed = 200f;
    public float nextWaypointDistance = 3f;

    Path Path;
    float currentWaypoint = 0f;
    bool reachedEndOfPath = false;

    Seeker seeker;
    Rigidbody2D rb;

    void Start()
    {
        seeker = GetComponent<Seeker>();
        rb = GetComponent<Rigidbody2D>();

        seeker.StartPath(rb.position, target.position, OnPathComplete);
    }

    void OnPathComplete(Path p)
    {
        if (!p.error)
        {
            Path = p;
            currentWaypoint = 0f;
        }
    }

    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).normalized;
        Vector2 force = direction * speed * Time.deltaTime;

        rb.AddForce(force);

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

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

    }
}

Like the error says, make currentWaypoint be an integer rather than a float.

1 Like

thanks but i already knew that my question was how to fix it according to the code, but you did inspire me in a way and found out how to fix it so thanks!

1 Like

I try, I really do try. :slight_smile:

1 Like