Movement like dungeon crawling

After seeing the forum I did not find the answer. Is it possible to make the movement of the enemy in the Dungeon Crawler genre of games such as Eye Of The Begolder or Legend Of Grimrock. With the help of Astar Path, I recreated the grid and it went perfectly to the level, but I do not understand how to make the enemy move along this grid, with the ability to rotate exactly 90 degrees. Please, help. Sorry for my English.

Hi

Have you checked out the get started tutorial? That shows you how to make an agent move in a grid: https://arongranberg.com/astar/docs/getstarted.php
If you want very grid-like movement you could use the AILerp movement script. See for example the example scene called 2D (at least I think that uses the AILerp movement script, I’m not 100% sure right now). See https://arongranberg.com/astar/docs/movementscripts.html

I created the perfect grid I think. The connection lines are fine.

I want to write my behavior.

  • I have 3 actions, Moving forward and turning right / left. They work perfectly without a grid.
    public void Move()
    {
        if (!_movementProcess && !_rotateProcess)
        {
            movementPoint = transform.position + (transform.forward * 2.4f);
            _movementProcess = true;
            action = true;
        }
    }

    public void RotateLeft()
    {
        if (!_movementProcess && !_rotateProcess)
        {
            endRotation = transform.rotation * Quaternion.Euler(0, -90, 0);

            _rotateProcess = true;
            action = true;
        }
    }

    public void RotateRight()
    {
        if (!_movementProcess && !_rotateProcess)
        {
            endRotation = transform.rotation * Quaternion.Euler(0, 90, 0);

            _rotateProcess = true;
            action = true;
        }
    }
  • I have an opponent’s “brain” timer. After this timer, I invoke one action (for example, every second) - Attack \ Move Forward \ Turn.

Task:
Every time when the timer is triggered, calculate a new path and, depending on the need, perform either a turn or move forward. How can I do this? How can I calculate the path and determine whether to make a turn or just move forward?

I really hope for your help!

Hi

You can take a look at this tutorial: https://arongranberg.com/astar/docs/custom_movement_script.html
Generally you will want to swap out the movement logic in that script with your movement/rotation calls. You can check if the agent should rotate by for example calculating Vector3.Angle(currentWaypoint - transform.position, Vector3.forward).