Avoiding AI from getting stuck

Hello,
When creating an AI character I have a empty game object and the AI under this object. I am running into an issue where the ai tried to go up/down before going all the way to the left/right. For example:

Is the only way to avoid this is keep changing the game object on the AI character so that it is not in the same spot? Or maybe add more force to the object so it “over shoots” the target area it was trying to hit?

Hi

First off, it seems that your graph has an extremely high resolution for your game. I think you should use maybe 1 or possibly 2x2 nodes per tile in your game.
In any case the setting you are looking for is the Seeker -> Start End Modifier -> End Point setting. By default it will pick the point on the node that is closest to the target point, however you likely just want it to use the center of the node instead, so I suggest you change the setting to ‘SnapToNode’.

Thanks. This helped me solve a lot of issues.

I am trying to get my AI to strafe back and forth over a player. Could you suggest an algorithm for me to use for this?

Below, I am just basically using the rigid body and increasing the velocity of it to the next waypoint with a certain speed. When I used rb.AddForce it created a rubberband effect where it would slingshot back and forth. I am not too sure how I have create a strafing effect against the target.

Vector3 dir = (path.vectorPath[currentWaypoint] - transform.position);
   // If the target is more then 1 away from us, then we will move toward the target
    if(target.position.x - rb.transform.position.x > 1)
    {
        rb.velocity = new Vector2(speed, rb.velocity.y);
    } else
    {
        rb.velocity = new Vector2(-speed, rb.velocity.y);
    }
   // 
    double yPosition = dir.y;

    // If the player is above us and we are grounded, then we jump
    if ((yPosition > 1) && IsGrounded())
    {
        // Jump
        rb.AddForce(new Vector2(0, 15), ForceMode2D.Impulse);
    }

    // Go to the next waypoint
    float dist = Vector3.Distance(transform.position, path.vectorPath[currentWaypoint]);
    if (dist < nextWaypointDistance)
    {
        currentWaypoint++;
        return;
    }

I’m not quite sure what you mean by ‘strafe back and forth over a player’?

I want the ai to walk left to right on the player. so say if the player is at position x =10, the ai will go to the player and walk back and forth from x=5 to x=15. I was thinking of just having 2 float variables that store the position of each x value and have a boolean called isWalkingRight, so if the block is walking to the right, it would go to the furthest waypoint to the right (x=15 in this example), then set it to false and it would go to the lowest waypoint (x=5 in this example). Do you think this is an efficient way of doing this or perhaps is there a better way?

Hi

You could simply set the destination of the AI to a point to the right of the player, and then when that point is reached you could change the destination to a point left of the player.