How to Show a Path to a Target | AI Series Part 31 | Unity Tutorial

Поделиться
HTML-код
  • Опубликовано: 19 дек 2024

Комментарии • 52

  • @K.Z007
    @K.Z007 Год назад +2

    Whenever I want to add something new to my game, your channel is the top one to go to. You are amazing.

    • @LlamAcademy
      @LlamAcademy  Год назад +1

      🧡 thank you! That made my day

  • @ahmedsiddique2998
    @ahmedsiddique2998 Год назад +1

    what about if our player is on height and the target is below your character i tried it goes through the ground cause navmesh is build on it

  • @dustypants9326
    @dustypants9326 3 года назад +2

    i didnt kno i needed this. I like the path to line renderer.
    In the past, i have spawned a "wisp" (particles + nav agent) to guide the player. But wisps were only good for hinting, and not all players follow hints.

    • @LlamAcademy
      @LlamAcademy  3 года назад +2

      I bet you can get some cool effects with that approach too!

  • @michalbusik8621
    @michalbusik8621 Год назад

    Hi, great tutorial, thank you. What do i need if i only want to draw path to the selected point? Without creating of new ring?

    • @LlamAcademy
      @LlamAcademy  Год назад

      You can just remove the code related to spawning the ring and keep only the drawing the path portion and it will work just fine

    • @michalbusik8621
      @michalbusik8621 Год назад

      @@LlamAcademy You mean the "SpawnNewObject" function? Anyway, i still have a problem with running the script. I have the same error as @3mmotion down in the coments. On the line wih Triangulation.Verticies in SpawnNewObject() it says that "Index is outside of the bounds of the array". I think it has somethign to do with navmesh because Trinagluation.Verticies has a value of 0 for some reason so than it cant calculate the path. I even tried it with your project from github and it does the same thing.

  • @klausbdl
    @klausbdl Год назад

    if you're doing it with some kind of ai agent that the path can change while the coroutine is running, remember to update the NavMeshPath path INSIDE the while loop

    • @doctoraquisio7957
      @doctoraquisio7957 Месяц назад

      sorry for necroposting but how should I update it?

  • @intimidate2161
    @intimidate2161 Год назад +1

    I was getting error on line 50. It was related to the line render path. I changed it to "Path" and its working now.

  • @jhonuribe171
    @jhonuribe171 9 месяцев назад

    I use this for a vehicle but I don't get the lines, I don't get an error and I don't know where I'm failing, I checked that everything was fine and the only difference is that you use a thirpesoncontroller and I don't

  • @shepa9832
    @shepa9832 3 года назад +1

    everything is cool, but brother, how did you add NavMesh Components in project? I don't see him in PackageManager...

    • @LlamAcademy
      @LlamAcademy  3 года назад

      I added it by modifying the manifest.json. I describe how I add it in part 1: ruclips.net/video/aHFSDcEQuzQ/видео.html

    • @shepa9832
      @shepa9832 3 года назад +1

      @@LlamAcademy aa cool thanks)

  • @toborcomedy
    @toborcomedy 2 года назад +1

    I don’t understand why this doesn’t even work when I download the source project file. Been trying for hours but I can’t get this line to show up! No errors, everything is linked just like the tutorial. Made sure to set everything. Ring is a collectible. Layers are good. Project settings physics are right

    • @LlamAcademy
      @LlamAcademy  2 года назад

      Hi 👋! I checked out the project from GitHub and just clicked play and it was working on 2019.4 LTS with Built In RP (same as I used in the video). Double check your LineRenderer settings to be sure it's enabled, has a material, and is hooked up to the "Path" property of the Collectable Spawner. It should work with URP no problem, but you'd have to do the material conversions

    • @toborcomedy
      @toborcomedy 2 года назад +1

      @@LlamAcademy I appreciate you still commenting and trying to help even a year after! I downloaded the same unity version just to further try and replicate. Unfortunately I still cannot get this line to show up. Would you mind taking a look at this imgur i created? I just downloaded what you had and put together like the video and for the life of me can't find what's going wrong. imgur.com/a/iesI2ZX appreciate it thanks!

    • @LlamAcademy
      @LlamAcademy  2 года назад

      If you check “Use World Space” on that Line Renderer does it fix it for you? That’s one difference I spot here and we’re setting positions in world space so it might do it!
      Thanks for sending all those screenshots, it really helps understand what could be going on!

    • @toborcomedy
      @toborcomedy 2 года назад +1

      @@LlamAcademy Just tested it out and still the indexoutofbounds:
      IndexOutOfRangeException: Index was outside the bounds of the array.
      CollectableSpawner.SpawnNewObject () (at Assets/Scripts/CollectableSpawner.cs:36)
      CollectableSpawner.Start () (at Assets/Scripts/CollectableSpawner.cs:31)
      I'll continue poking around trying to find fixes :(

    • @toborcomedy
      @toborcomedy 2 года назад +1

      Triangulation.vertices has to be an empty array with 0 elements

  • @Strongest845
    @Strongest845 11 месяцев назад

    is this possible to move objects along navmeshpath with rigidbody, not using navmeshagent ?

    • @LlamAcademy
      @LlamAcademy  11 месяцев назад

      Yes, you can use NavMesh.CalculatePath() still to get a path, but I'm not sure what the use case is for using a Rigidbody if you're going to just follow the path.

    • @Strongest845
      @Strongest845 11 месяцев назад

      @@LlamAcademy I want to do knockback effect, or jumping without offmeshlink, biggest example is risk of rain 2, where enemies can be knock up to the sky, something I am struggle with agent

    • @LlamAcademy
      @LlamAcademy  11 месяцев назад +1

      @@Strongest845 hmm… stay tuned for next week’s video maybe that will help 😉

    • @Strongest845
      @Strongest845 11 месяцев назад

      @@LlamAcademy i have made my rigidbody, or character controller kind of worked, i will get the move direction by get the path[1] - path[0], the problem rise at corner,it stand still at the corner, it maybe conflict by path[1] and path[0] too close at other, some time it stop frezze at corner and continue movement

  • @newbossbro3180
    @newbossbro3180 Год назад

    Is there any room for improvement? Let's say calculating when the target position is on different polygon then recalculate, if its same then simply changing vector position

    • @LlamAcademy
      @LlamAcademy  Год назад

      Yes of course there's room for improvement! I think it may be more computationally expensive to calculate which triangle the player is on from the NavMesh Triangulation than it would be to just calculate a new path though.

  • @swaranagatabose4782
    @swaranagatabose4782 9 месяцев назад

    ActiveInstance = Instantiate(Prefab,
    Triangulation.vertices[Random.Range(0, Triangulation.vertices.Length)] + Vector3.up * SpawnHeightOffset,
    Quaternion.Euler(90, 0, 0)
    ); Comes an error in this line "index was outside the bounds of the array" please tell me how can i solve it?

  • @yours_indie_game_dev
    @yours_indie_game_dev Год назад

    so if i spawn navemesh obstacles in runtime will i have to rebake the surface

    • @LlamAcademy
      @LlamAcademy  Год назад

      Obstacles, no. Modifiers, yes.

    • @yours_indie_game_dev
      @yours_indie_game_dev Год назад

      @@LlamAcademyi spawn some obstacles at runtime the line goesthrough them it only shows correctly when i rebake the navmesh

  • @Epic_AiShorts
    @Epic_AiShorts 3 года назад +1

    is this possible in 2d game?

  • @nileshkumawat2997
    @nileshkumawat2997 2 года назад

    Hey you know about terrain Material? I am using curve world shader for game but this material when I use on terrain I can't able to paint texture on terrain but in normal default lit material we can paint texture.... So you know? What is problem in my shader material

    • @LlamAcademy
      @LlamAcademy  2 года назад +1

      You have to have special shaders for terrains. Just a standard shader won’t work there. Your curved world shader probably is only for standard object rendering and doesn’t support terrain rendering.

  • @t.t.9999
    @t.t.9999 3 года назад

    57 lines of code doesnt work. why? Where else should I calculate the path?

    • @LlamAcademy
      @LlamAcademy  3 года назад +1

      Sorry I'm not sure I understand the question. You can check out the repository on GitHub github.com/llamacademy/ai-series-part-31 and compare what you have to what I've done in the project.

  • @dwikyanderson5039
    @dwikyanderson5039 2 года назад

    the ActiveInstance is outside the bounds of array can someone help me

    • @LlamAcademy
      @LlamAcademy  2 года назад

      Can you share the full error you're getting as well as what's not working? ActiveInstance is not an array so the error as you posted sounds like you may have some differences from what I have on the GitHub project: github.com/llamacademy/ai-series-part-31

  • @alperaydin7011
    @alperaydin7011 3 года назад +2

    Thanks

  • @diegoguzman5717
    @diegoguzman5717 Год назад +1

  • @neilfosteronly
    @neilfosteronly Год назад

    Is the line always Agent Type Humanoid or first in the list? Any way to change what areas it can navigate? Thanks for these videos. You have the best tutorials for Unity right now.
    Edit: I see how it works now. NavMesh.AllAreas so it can walk everywhere.
    Here is what I used for the Line to only go on some areas.
    NavMesh.CalculatePath(Player.position, nearestOBJ.transform.position, NavMesh.GetAreaFromName("Road") | NavMesh.GetAreaFromName("Terrain"), path

    • @artinstroukeprod
      @artinstroukeprod 7 месяцев назад

      I try to build a path solely on a specific zone like in your example and still the path is built on "Walkable" area... ((