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 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.
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
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
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
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
@@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!
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!
@@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 :(
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.
@@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 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
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
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.
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?
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
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.
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.
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
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
Whenever I want to add something new to my game, your channel is the top one to go to. You are amazing.
🧡 thank you! That made my day
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
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.
I bet you can get some cool effects with that approach too!
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?
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
@@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.
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
sorry for necroposting but how should I update it?
I was getting error on line 50. It was related to the line render path. I changed it to "Path" and its working now.
Glad you got it working!
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
everything is cool, but brother, how did you add NavMesh Components in project? I don't see him in PackageManager...
I added it by modifying the manifest.json. I describe how I add it in part 1: ruclips.net/video/aHFSDcEQuzQ/видео.html
@@LlamAcademy aa cool thanks)
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
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
@@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!
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!
@@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 :(
Triangulation.vertices has to be an empty array with 0 elements
is this possible to move objects along navmeshpath with rigidbody, not using navmeshagent ?
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.
@@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
@@Strongest845 hmm… stay tuned for next week’s video maybe that will help 😉
@@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
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
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.
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?
so if i spawn navemesh obstacles in runtime will i have to rebake the surface
Obstacles, no. Modifiers, yes.
@@LlamAcademyi spawn some obstacles at runtime the line goesthrough them it only shows correctly when i rebake the navmesh
is this possible in 2d game?
Absolutely!
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
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.
57 lines of code doesnt work. why? Where else should I calculate the path?
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.
the ActiveInstance is outside the bounds of array can someone help me
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
Thanks
You're welcome!
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
I try to build a path solely on a specific zone like in your example and still the path is built on "Walkable" area... ((