Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

A* for with some leeway for my AI

Discussion in 'Navigation' started by jnbbender, Mar 7, 2018.

  1. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    I would like to use an A* algorithm or even get away with a simple waypoint system for my racing style/flying AI. But if I used a waypoint system is there a way to give it some leeway to may it look like it's flying on curved trajectories. They would be using Rigidbody physics and if they stray off the path a certain amount that would be great. Any ideas?
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    If you're planning to use Unity's built-in Navmesh system with physics-based agents, you can disable the agent's transform updates (so that it doesn't move the game object) and still access the pathfinding data the agent generates. For example, this will tell you the bearing and distance to the target. You can then use this information to apply whatever forces make sense in your game to get your vehicle to that point. But you'll need to determine the forces needed to get from A to B smoothly (such as by using a PID controller)
     
  3. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    That's actually not a bad idea. But my NPC is in the air so no Unity NavMesh :(
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    I've been keeping an eye on this asset:

    https://assetstore.unity.com/packages/tools/ai/pathfinder-3d-100285

    It's relatively new, but after a bit of research it seems like the approach I plan to use in the near future to deal with pathfinding for flying-based NPCs. I can't speak to its quality, and I'm not associated with the project in any way, but it seems like a promising approach to pathfinding in a full 3D, rather than a mesh-based approach.
     
  5. jnbbender

    jnbbender

    Joined:
    May 25, 2017
    Posts:
    486
    Funny you mention that. I just purchased it the other night and I'm beating my head against the ground with it. I asked for my money back but then I figured I'd give it another shot. I expected it to be pretty plug-n-play but it's DEFINITELY NOT. The documentation is very crude and to implement Pathfinding you have to code, at least some. So now I'm stuck reading the code to figure out how this should work. I figured I'd give it a shot -- the developer did say he'd give me my money back though.
     
  6. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Thanks, that's useful feedback. In my case, I'm actually hoping it's not very plug-and-play: I just want the pathfinding data from the asset, I don't want it to actually control the movement of my objects for me. I won't be starting work on that part of my project for a couple of months, but I'll try to come back and update this post with my findings at that point. Good luck.