AI Follow Component

The AIFollow script isn’t part of the A* Pathfinding system, it is included in the project as an example script.
The main function for this script is to move characters around. If attached to an object with a Seeker component, it will receive the generated path from the seeker.

AIFollow.cs

Functions

Receives

PathComplete

The Seeker script sends the generated path through this function

PathError

The Seeker script calls this if the pathfinding returned an error

Variables

Speed

The speed of the unit (m/s)

Rotation speed

The speed with which the unit will turn around

Pick Next Waypoint Distance

The minimum number of meters the unit must be from a waypoint before following it

Search Waypoint Frequency

The number of seconds between each search for the next waypoint

Max Stop

The minimum number of meters the unit must be from the end of the path before stopping

Continuous target search

If checked, the AI will continuously search for the Target in regular intervals based on the next variable

Target search frequency

The number of seconds between each target search

Command

The command the unit is performing right now (standing still or walking, ‘Stay’, ‘Walk’)

Target search frequency

The number of seconds between each target search

11 Responses to AI Follow Component

  1. chrisB says:

    Just getting started using your Pathfinding-system.
    Any word on when the doc for AI Follow will come (back) ?

    Thanks a lot!

    -C

  2. Admin says:

    Oops, I had forgot about that, I will fix it ASAP (don’t read the docs myself you see ; )

  3. Admin says:

    Now it’s up!

  4. Jiwan says:

    Is there any function for this script that stops the character if it meets the obstacle on the way?

  5. Admin says:

    See the answer to this question in the Get Started With A* – Part 3 comments – Comment 28.

  6. Raihje says:

    Ok, so everything in the demo worked fine, but I’m trying to make a maze, and you go
    around and “rescue goblins” (your a goblin) avoiding the dragonkin that (until a fix a
    bug) will cut you in half with one (rapid-fire) fell sweep of his big sword. But, I put the
    AIFollow.cs script (I use JS, not cs, so I have no idea what it’s doing really >->) but it
    says

    Assets/Standard Assets/Pathfinding/AIFollow.cs(20,17): error CS0246: The type or namespace name `AIAnimation’ could not be found. Are you missing a using directive or an assembly reference?

    How can I fix this? And any ideas on how I can make sure the Goblins can follow the
    player around the maze efficiently? (Also, traps and rotating walls, and all sorts of
    stuff will be in there too, so Pathfinding might be a challenge for the average goblin xD)

  7. Raihje says:

    Oh side note – I deleted any “animator” and “AIAnimation” strings anywhere (including
    whatever had that inside it, so the Stop() (if whatever animation etc..) And then it
    gave me a parsing error, but that was the only error and it pointed to a line that
    (imo) shouldn’t be an error.

    Assets/Standard Assets/Pathfinding/AIFollow.cs(131,29): error CS8025: Parsing error the line just said
    direction.y = 0;
    So you can see my predicament? I have 4 days tops to get this working before my
    team throws me in a guillotine lol. I hate unity, but it’s what we have to use for this
    job so for now I’m gritting for the 2,000 bucks I’m making this month :S

    Next time I have to choose a job description for a game, I’m choosing artist or
    Designer, programmers have it too hard with unity, being forced to learn something in
    like… a week flat is a pain :P I think I’d be a decent designer, I know a little about
    everything, not enough to really specialize >->

  8. Raihje says:

    Ook, I managed to bring all the errors down to one – it says StarPath() doesn’t exist.
    That seems to be the only issue now. Realized “Animation” and stuff was in the other
    folder lol – Fail..

    Alright. So, any pointers or help, would be dually nice..

  9. Raihje says:

    Ok all the errors are gone :P Awesome, managed to get my own little demo level going!
    I only have one last small issue. If you have 1 one. make him go to one side, then ask him
    to go to the other side, he stands there with a blue line going right to the other side of
    the wall. I tried cutting in half the grid radius thing, and the height, didn’t do anything.
    is there any way I can reduce his.. LOS to only see a square in front of him?
    He can go around corners pretty good for the most part, the blue line kinda has to drag
    him a bit sometimes but that’s fine as far as I’m concerned. But I don’t want the
    character to double back along a wall and have the AI get stuck because he’s only on
    the other side of a wall – still unreachable though.

  10. Raihje says:

    Ok I fixed everything except, unless your reallllly careful, you get some “Start is not
    Within Grid” and he’s in plain sight of a grid. Like he couldn’t not stray from the grid the
    way the level is designed. It’s just weird. I need to solve it because the cube sits there
    stupidly, while I walk all around. In the Debug it looks like he’s just frozen with a rapid
    fire blue line (raycast?) in front of him. Friggen annoying. So close to having everything
    perfect, and something small like this tears the whole game apart. Goblin friends can’t
    follow you, if 1 cube can’t even follow you.

  11. Admin says:

    Hi Raihje

    Ok, you seem to have found the solutions to most of the problems, I have been without internet for a week so I haven’t been able to answer.

    From what I can understand, your scene is laid out flat and I guess the grid offset in the A* settings is set to 0 on the Y axis.
    Try to change the Y offset to -0.1 (just so the grid’s bound’s bottom isn’t exactly in line with the ground), it’s probably floating point errors which causes the problem (just because your goblin seems to be placed on Y position 0 it could be -0.0001 which would cause the IsPositonInsideBounds check to fail).

    PS: The thing with the goblins getting stuck at corners, try checking the toggle Don’t Cut Corners in the A* Settings, hopefully it will help.

    Hope it helps,
    Aron

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>