One thing that's worth noting if you feel like it would suit your project is that you can actually calculate a path on a navmesh without having to use a navmesh agent. In my project I got annoyed by the lack of physics on agents and ended up just making my own physics based agent. It's as simple as calculating a path, getting the next point in the path, applying a force to make my agent face it, then applying a forward force to push the agent along.
can you please elaborate on how you follow the path? like what I am understanding is we calculate the navmesh path from source to target, but how do you make it follow bit by bit?
@dbweb.creative When you calculate a navmesh path it outputs an array of points for each point along the path. point 0 is always where the agent currently is and point 1 is the next point along the path. The destination that you're navigating to will always be the final point in the array. This means you just have your agent always move towards point 1 and once your agent reaches point 1 you update the path so that the next point becomes point 1. (If your agent is navigating towards a moving target you'll need to update the path on an interval like every frame rather than updating it when the agent reaches point 1)
@@dbweb.creative I just wrote a whole long response but it looks like it vanished for some reason. Essentially though dynamic avoidance of objects that aren't baked into the navmesh is actually a problem that's better solved on top of the base pathfinding rather than attempting to work it into the pathfinding itself. There are alot of different methods but the one that I have had the most luck with is called dynamic steering. Game Endeavour has a really good video about it called "The Trick I Used to Make Combat Fun" he also links a really good article in the description talking about it. It's definitely worth a watch. Basically though, the way it's implemented in my game works like this: I have an array of directions that my NPC can choose to move in that essentially forms a circle around him. I also have an array of weights that are just floats. The weights array has the same number of elements as the directions array so that I can correspond them 1 to 1 (weight[0] corresponds to direction[0], weight[6] corresponds to direction[6], etc). I send out a series of raycasts along each direction. If one of the raycast hits something that my NPC wants to avoid then I use Vector3.Dot to increase the weights that point away from that object. While doing this I'm also plugging in the direction to point 1 on my navmesh path and increasing the weights that point towards it. From there I just determine which weight is the highest and then output the corresponding direction as a Vector3 that my NPC moves towards. This results in an NPC that will try to move towards the destination I want while avoiding obstacles.
@@dbweb.creative I just wrote a whole long response but it looks like it vanished for some reason. Essentially though dynamic avoidance of objects that aren't baked into the navmesh is actually a problem that's better solved on top of the base pathfinding rather than attempting to work it into the pathfinding itself. There are alot of different methods but the one that I have had the most luck with is called dynamic steering. Game Endeavour has a really good video about it called "The Trick I Used to Make Combat Fun" he also links a really good article in the description talking about it. It's definitely worth a watch. Basically though, the way it's implemented in my game works like this: I have an array of directions that my NPC can choose to move in that essentially forms a circle around him. I also have an array of weights that are just floats. The weights array has the same number of elements as the directions array so that I can correspond them 1 to 1 (weight[0] corresponds to direction[0], weight[6] corresponds to direction[6], etc). I send out a series of raycasts along each direction. If one of the raycast hits something that my NPC wants to avoid then I use Vector3.Dot to increase the weights that point away from that object. While doing this I'm also plugging in the direction to point 1 on my navmesh path and increasing the weights that point towards it. From there I just determine which weight is the highest and then output the corresponding direction as a Vector3 that my NPC moves towards. This results in an NPC that will try to move towards the destination I want while avoiding obstacles.
I built a physics-based knockback system on navmesh enemies very recently. Can't wait to see how you handle it to compare notes. Something tells me I'm gonna need to do some re-writes after I finish watching...
😁 I'd love to hear about your implementation! I know some people will use the NavMesh and push back solely on the NavMesh. I found that more complex than this solution
Awesome tutorial, as always! Your dedication to these guides is truly inspiring. I have a quick suggestion about your closing intro line: while I appreciate the lighthearted spirit of "Who me, yes you," I find it a bit childish and annoying with this changing voice… Personally, I'm much more drawn to your empowering statement, "Here to help you make your Game Dev dreams become reality." It simply feels more mature and really resonates with me and feels perfectly consistent with your overall message. I wonder if it might be interesting to poll your viewers and see what they prefer?
Thanks for the feedback. Do you dislike the entire "yes you" portion or do you feel I'm taking it a little over the top with the voice changing and all that around it?
@@LlamAcademy I personally find the "Who me, yes you" (only this 4 words) line a bit annoying and I'd really enjoy hearing your natural tone without the pitch shift. I think it would create a more natural and engaging connection with the audience.
@@PRodi_ I appreciate that. I may have gotten a little carried away with that part and I agree it can feel like it cheapens the sincerity of the part that is meaningful.
You can probably take the path calculation from here (really just NavMesh.CalculatePath) th-cam.com/video/scaBHHFKLL0/w-d-xo.html Then apply force to the rigid body in the direction of the next corner
How many knocks would an IKnockbackable knock back if an IKnockbackable could knock back? A great video tutorial! I had a similar problem a year or so ago and had no ends of pain since I didn't know Agent.Warp existed. RTFM, I know.
I'm actually using www.youtube.com/@danielilett 's method for outlines I learned about it here: th-cam.com/video/VGEz8oKyMpY/w-d-xo.htmlsi=IlmsCu8-hiJR8kMh
This is good, but I think it's a lot of work to work around the limitations of the built in Unity navmesh agents system. I prefer to use Aaron Granberg's A* implementation and have rigidbodies active all the time so that they can be knocked or pushed by anything at any time.
I don’t, but the shader graphs are included in the repo. There’s 2 needed for the effect: a full screen outline shader (set up on URP asset) and a toon shader (on the material for each object) to get this look.
I'm meeting an issue right now as I've just discovered unity organisations and ready to make my first whole game. I'm scared about the legal rules around purchased assets when working in a team thru unity plastic scm. It would be great to have a video describing things like seats and how to "do it right" when using outsourced assets in a publicly released game
Nice tutorial and very useful to make you game feel less static! I have a question: how can you get nav agent back on NavMesh if its gets knocked out of it? I have AI npc's that use character controller to move, but sometimes if they run too fast or get knocked they get off nav mesh and get stuck. If i just do Warp to closest nav mesh point it wont fix the problem since i need to move the whole character back to navmesh again. Maybe you have some good solution for this? Thanks!
Warping is the only built in method of getting the agent “back on the navmesh”. Remember the navmesh is the representation of walkable (or otherwise traversable) areas of the AI. If they’re off this then something really bad happened. Perhaps in the closing segment of this video those ideas could help. Depending on how “off” they are and how your scene is configured, you may be able to just lerp or move them back following a curve, then warp them to that position.
Dude, legit exactly what i was looking for, i was tryna make this work for a while. TY!
I've really enjoyed this series, thanks :-). It's answered some questions I've had, not just for AI.
One thing that's worth noting if you feel like it would suit your project is that you can actually calculate a path on a navmesh without having to use a navmesh agent. In my project I got annoyed by the lack of physics on agents and ended up just making my own physics based agent. It's as simple as calculating a path, getting the next point in the path, applying a force to make my agent face it, then applying a forward force to push the agent along.
can you please elaborate on how you follow the path? like what I am understanding is we calculate the navmesh path from source to target, but how do you make it follow bit by bit?
@dbweb.creative When you calculate a navmesh path it outputs an array of points for each point along the path. point 0 is always where the agent currently is and point 1 is the next point along the path. The destination that you're navigating to will always be the final point in the array. This means you just have your agent always move towards point 1 and once your agent reaches point 1 you update the path so that the next point becomes point 1. (If your agent is navigating towards a moving target you'll need to update the path on an interval like every frame rather than updating it when the agent reaches point 1)
also how do you handle avoidance between NPCs if they are not navagents?
@@dbweb.creative I just wrote a whole long response but it looks like it vanished for some reason. Essentially though dynamic avoidance of objects that aren't baked into the navmesh is actually a problem that's better solved on top of the base pathfinding rather than attempting to work it into the pathfinding itself.
There are alot of different methods but the one that I have had the most luck with is called dynamic steering. Game Endeavour has a really good video about it called "The Trick I Used to Make Combat Fun" he also links a really good article in the description talking about it. It's definitely worth a watch.
Basically though, the way it's implemented in my game works like this:
I have an array of directions that my NPC can choose to move in that essentially forms a circle around him. I also have an array of weights that are just floats. The weights array has the same number of elements as the directions array so that I can correspond them 1 to 1 (weight[0] corresponds to direction[0], weight[6] corresponds to direction[6], etc). I send out a series of raycasts along each direction. If one of the raycast hits something that my NPC wants to avoid then I use Vector3.Dot to increase the weights that point away from that object. While doing this I'm also plugging in the direction to point 1 on my navmesh path and increasing the weights that point towards it. From there I just determine which weight is the highest and then output the corresponding direction as a Vector3 that my NPC moves towards. This results in an NPC that will try to move towards the destination I want while avoiding obstacles.
@@dbweb.creative I just wrote a whole long response but it looks like it vanished for some reason. Essentially though dynamic avoidance of objects that aren't baked into the navmesh is actually a problem that's better solved on top of the base pathfinding rather than attempting to work it into the pathfinding itself.
There are alot of different methods but the one that I have had the most luck with is called dynamic steering. Game Endeavour has a really good video about it called "The Trick I Used to Make Combat Fun" he also links a really good article in the description talking about it. It's definitely worth a watch.
Basically though, the way it's implemented in my game works like this:
I have an array of directions that my NPC can choose to move in that essentially forms a circle around him. I also have an array of weights that are just floats. The weights array has the same number of elements as the directions array so that I can correspond them 1 to 1 (weight[0] corresponds to direction[0], weight[6] corresponds to direction[6], etc). I send out a series of raycasts along each direction. If one of the raycast hits something that my NPC wants to avoid then I use Vector3.Dot to increase the weights that point away from that object. While doing this I'm also plugging in the direction to point 1 on my navmesh path and increasing the weights that point towards it. From there I just determine which weight is the highest and then output the corresponding direction as a Vector3 that my NPC moves towards. This results in an NPC that will try to move towards the destination I want while avoiding obstacles.
Thank you very much!! This video really helped me.
Thanks, this was really helpful!
I built a physics-based knockback system on navmesh enemies very recently. Can't wait to see how you handle it to compare notes.
Something tells me I'm gonna need to do some re-writes after I finish watching...
😁 I'd love to hear about your implementation! I know some people will use the NavMesh and push back solely on the NavMesh. I found that more complex than this solution
Awesome tutorial, as always! Your dedication to these guides is truly inspiring.
I have a quick suggestion about your closing intro line: while I appreciate the lighthearted spirit of "Who me, yes you," I find it a bit childish and annoying with this changing voice…
Personally, I'm much more drawn to your empowering statement, "Here to help you make your Game Dev dreams become reality." It simply feels more mature and really resonates with me and feels perfectly consistent with your overall message.
I wonder if it might be interesting to poll your viewers and see what they prefer?
Thanks for the feedback. Do you dislike the entire "yes you" portion or do you feel I'm taking it a little over the top with the voice changing and all that around it?
@@LlamAcademy I personally find the "Who me, yes you" (only this 4 words) line a bit annoying and I'd really enjoy hearing your natural tone without the pitch shift. I think it would create a more natural and engaging connection with the audience.
@@PRodi_ I appreciate that. I may have gotten a little carried away with that part and I agree it can feel like it cheapens the sincerity of the part that is meaningful.
@PRodi_ What a blockhead statement to make bro, the mans made a good vid. Keep doing you @LlamAcademy man, great vid
Thanks for making this video
Welcome ☺
@@LlamAcademy You also.
Another amazing video. Thanks Liam !
Chris the legend! 😎
Thanks for the tutorial
🙏
workout tutorial pls
step 1: lift heavy thing
step 2: get big 💪
😜
Could you please make a video on the method of extracting the path and then setting the rigidbodies velocity toward the next path node?
You can probably take the path calculation from here (really just NavMesh.CalculatePath)
th-cam.com/video/scaBHHFKLL0/w-d-xo.html
Then apply force to the rigid body in the direction of the next corner
How many knocks would an IKnockbackable knock back if an IKnockbackable could knock back?
A great video tutorial! I had a similar problem a year or so ago and had no ends of pain since I didn't know Agent.Warp existed. RTFM, I know.
😆
can you make a tutorial about the outlines in our game?
I'm actually using www.youtube.com/@danielilett 's method for outlines I learned about it here: th-cam.com/video/VGEz8oKyMpY/w-d-xo.htmlsi=IlmsCu8-hiJR8kMh
This is good, but I think it's a lot of work to work around the limitations of the built in Unity navmesh agents system. I prefer to use Aaron Granberg's A* implementation and have rigidbodies active all the time so that they can be knocked or pushed by anything at any time.
That is a great system that does avoid a lot of the limitations of the built in navigation system.
very cool dude..
Thanks ☺
Do you have a tutorial for this shader sir?
I don’t, but the shader graphs are included in the repo. There’s 2 needed for the effect: a full screen outline shader (set up on URP asset) and a toon shader (on the material for each object) to get this look.
I'm meeting an issue right now as I've just discovered unity organisations and ready to make my first whole game. I'm scared about the legal rules around purchased assets when working in a team thru unity plastic scm. It would be great to have a video describing things like seats and how to "do it right" when using outsourced assets in a publicly released game
Nice tutorial and very useful to make you game feel less static! I have a question: how can you get nav agent back on NavMesh if its gets knocked out of it? I have AI npc's that use character controller to move, but sometimes if they run too fast or get knocked they get off nav mesh and get stuck. If i just do Warp to closest nav mesh point it wont fix the problem since i need to move the whole character back to navmesh again. Maybe you have some good solution for this? Thanks!
Warping is the only built in method of getting the agent “back on the navmesh”. Remember the navmesh is the representation of walkable (or otherwise traversable) areas of the AI. If they’re off this then something really bad happened. Perhaps in the closing segment of this video those ideas could help.
Depending on how “off” they are and how your scene is configured, you may be able to just lerp or move them back following a curve, then warp them to that position.
What about a way so once you shoot them with a gun a random amount of times they ragdoll
I think for that you can just give them a random amount of life and apply damage per hit
Good day Liam, i hope u are doing well. how to make cinematic introduction scenes like short movie clip for game. whats the best way?
I think the "Timeline" package is what you're looking for
why not just change agent velocity to the force direction?
That can work for some game styles. However, the agent will still be stuck to the NavMesh. For a lot of game styles that will not look very good