Have a few issues I'm experiencing with A*, looking for ideas to fix them

Hey so I’m new to using this so I’m sure that theseare probably user error but I’m not having luck searching through the documentation or other forums on these that are kind of specific to my game.

Issue 1: When using the AI on a parent object to my actual game object, the AI will continue to stack on my target while the game object will stop at a certain point to attack. This leads to the AI parent object being in a different location than my game object and it causes serious navigation issues. Is there a way to prevent this from happening? I’m using RichAI, is there a way to possibly set a distance to stop way from my target than to stop directly on it?

Issue 2: If I put the AI directly on my game object instead of my parent it causes my physics interactions during Off Mesh Link traversals to be ignored. I apply a force upward on my character to cause it to jump over certain obstacles but the force isn’t applied if the AI isn’t a parent object.

Issue 3: Going along with the two issues above, I can’t seem to find an effective way to have my character jump during link transitions except to apply that force as described above. Is there a way I could do that easier?

I did not understand much of what was written, Google translator did a poor job.

I have already come up with two methods.
1.How to avoid big agent to overlap obstacles
2.Is there a function like BFS that would collect all the nodes in a list with a hurdle?

Games are different with direct and indirect control, 3d, 2d, etc. Each of these games has its own ways to make jumps. They are not in my project and I can not tell you how to do them. But on the Internet, I think there are many videos on this topic.

Hi

  1. You should have your AI on your main character GameObject. If a child and parent can move relative to each other you will likely get unexpected results.

You can set “When Reached Destination” to “Stop” and adjust the “endReachedDistance” field.

The RichAI will default to interpolating along off-mesh links. You can subscribe to the onTraverseOffMeshLink callback to controll off mesh-links completely yourself. See RichAI - A* Pathfinding Project

I think the onTraverseOffMeshLink callback will help you there as well. It allows you to control exactly what happens during an off-mesh link.

Thank you for the reply, I’m still struggling to understand how exactly to use the onTraverseOffMeshLink call back to customize the link traversal. Should I be putting that in my enemy controller script and customizing it there? Or should I be doing something with the RichAI script? If you wouldn’t mind explaining a little further or pointing me in the direction of a good tutorial on this it would be super helpful as I believe this is what I need.

Basically here is exactly what I want to achieve. When my enemy reaches an off mesh link I would like it to play an animation that I have and apply a jump force to the rigidbody to have my enemy arc over the obstacle in front of them. Currently this is my script on my enemy controller ultimately and the animation works just fine but the force will not be applied to the rigidbody on my gameobject with the richAI component connected directly to my object. The force is applied when its the parent of the gameobject, but not when its a direct component of the game object. Do you know what may be wrong?

Edit for further clarification: I am actually getting the jump force to apply, but it does not apply until after the traversal is complete. The animation will play at the start of the traversal, but the jump force isn’t applied until the end meaning my enemy goes right through the obstacle then jumps after where instead I want it to jump over the obstacle.

     void OnEnable()
    {
        richAi = GetComponent<RichAI>();
        if (richAi != null) richAi.onTraverseOffMeshLink += TraverseOffMeshLink;
    }

    void OnDisable()
    {
        if (richAi != null) richAi.onTraverseOffMeshLink -= TraverseOffMeshLink;
    }

void Update() {   
        if (richAi.traversingOffMeshLink && jumpCoolDown <= 0f)
        {
            RichPathPart currentPart = richPath.GetCurrentPart();
            StartCoroutine(TraverseOffMeshLink(currentPart as RichSpecial));
        }

        if (jumpCoolDown >= 0f)
        {
            jumpCoolDown -= Time.deltaTime;
        }

        richAi.destination = player.position;
    }

    IEnumerator TraverseOffMeshLink(RichSpecial link)
    {
        // Traverse the link over 1 second
        float startTime = Time.time;

        Jump();
        while (Time.time < startTime + 1)
        {
            transform.position = Vector3.Lerp(link.first.position, link.second.position, Time.time - startTime);
            
            yield return null;
        }
        transform.position = link.second.position;
    }

    private void Jump()
    {
        jumpCoolDown = 3f;
        animator.Play("Zombie Jump");
        rb.AddForce(Vector3.up * -rb.velocity.y, ForceMode.VelocityChange);
        rb.AddForce(Vector3.up * 7f, ForceMode.VelocityChange);
    }

@aron_granberg

Yes, it should be in a separate script. To avoid having to change the source code of this package.

Notice that in your current TraverseOffMeshLink function, you set the transform.position every frame. This will completely remove any effect of physics. You probably want to remove that position setting code if you want physics to govern your agent during the link traversal.