Support Forum

How to move character?

Hey guys - So I came across this wonderful project here and immediately wanted to use it for my 2d Top Down project.

So the navmesh is built in and scanned the way I want it to be. But I can’t move my characters that way because I only developed 3D games before and used the built-in Unity Navigation.

Is there no method like “setDestination” and the character moves to the position of the player?
With Move() the character moves in one direction and moves on and on and on and on and with FinilizeMove() it doesn’t move at all.

public class FollowTargetAction : ActionAI
{
    public override void use(UtilityAIHandler controller)
    {
        //controller.aiPath.Move(controller.target.transform.position);
        controller.aiPath.FinalizeMovement(controller.target.transform.position, Quaternion.identity);
    }
}

Is there a tutorial for this?

Hi

There are a lot of tutorials, check out https://arongranberg.com/astar/docs/getstarted.html.

Yes, use GetComponent<AIPath>().destination = somePoint.

For more info about the movement scripts, check out https://arongranberg.com/astar/docs/movementscripts.html

thanks aron - btw. why are those dudes stuck by obstacles when the path is right??

btw. how do I set it up that the enemies won’t stack on my player?

partially answered in How can i follow the path?

A* does not come with any positioning logic, it’s up to the end user to implement their own system. Aka it’s up to you to position your enemies around the player. RVO ( local avoidance) can be used to help, but it’s not a golden solution.