At 6:54 in the video you add the distance traveled to distance instead of to distanceTraveled so the platform never stops moving in the direction of the first point. A small bug but an important one.
Wow! Thank you for catching that and calling it out! That is a very important one. I double checked the GitHub repository and it looks like this was an error in the video, but in the repository it is correctly incrementing distanceTraveled. Anyone following along will need to be warned of this, and anyone who is copying scripts from GitHub will have it working correctly.
This is actually epic, imagine seeing Unity saying that this is not supported and then you make it happen and the limitations are also not really that big of a deal. Great job honestly.
Thank you! I was really surprised to find that you could achieve this with relative ease! The drawbacks...depending on your game type may be a deal breaker but there are lots of use cases that they are really inconsequential
Hi I tried to apply this to a moving elevator, but when I update the surface position some agents get stuck mid air, the surface update happen every frame but the agent update don’t(asynchronous), can it be the reason why they lose the surface position ?
Hi! You need to use the NavMesh Components (github.com/Unity-Technologies/NavMeshComponents) to get the NavMeshSurface. In the first video of the AI series I go over how to install it: ruclips.net/video/aHFSDcEQuzQ/видео.html
Hi, great videos! What if you want to move to a normalized speed from one platform to another ? I mean avoid to move in a higher speed when pass thro the NavMeshLink ? Thanks!
Good question! I've covered NavMeshLink traversal on a couple of other videos. The simple one was: ruclips.net/video/dpJUc_BpChw/видео.html (AI Series Part 2) and a more advanced one here: ruclips.net/video/PD6VFD1a21g/видео.html (AI Series Part 17). To shortly answer your question - you have full control over the agent while it traverses the NavMeshLink. You can calculate the distance they'll travel from the start/end points and move them over that distance using the Agent's current velocity, or target speed.
🤔docs.unity3d.com/Packages/com.unity.ai.navigation@1.1/api/Unity.AI.Navigation.NavMeshSurface.html#Unity_AI_Navigation_NavMeshSurface_collectObjects It seems like it should be there. This has always been an option on the Surface. Can you maybe reinstall your Navigation Components and see maybe something went wrong in the installation?
I have not. I imagine you'd do the exact same thing, but instead of updating the destination every frame, you would update the Agent's local rotation every frame by the same amount as the platform is rotating. I'll take a look and see if it's that simple and get back to you.
@@LlamAcademy kinda, you still have to move the player/agent. Say like a short and wide column that is rotating; The rotation and distance of the column has to be translated to the player's position and rotation.
Hmm... I think rebuilding the NavMesh would be the safest option for that. Depending on how far you're "Teleporting" you could just have 2 instances of whatever your player is on and have the teleport just warp the player between the two.
Great question! As long as the platforms don’t move too quickly I see no reason they won’t work for up/down movement as well. I haven’t tried that myself yet but based on how it works, I don’t expect any issues with that
@@LlamAcademy Ok, great! I will give it a shot. I see that you’re covering a ton of super useful topics(enemy surround, ai door behavior, hitscan tracers etc.) Can’t wait to dig into them. Subscribed!
I'm not entirely sure. I would not try to mix the NavMesh with Joystick / WASD movement. Instead, I would control it with a Character Controller or Rigidbody Controller and implement a jump. Any "Enemies" could be on a NavMesh to chase the player. That's how I implemented it on Llama Survival at least - the player runs around on the level with a Character Controller and all the zombies use the NavMesh with some NavMeshLinks to jump over gaps / obstacles.
Need to test it but could just when the agent goes onto the platform child the agent with the platform. Think potentially solve alot of the other limitations as the agent could you the local position then to move around on the platform movement speed would remain relevant because of be a child of the other agent I may be not calculating for something but I am positive that will work. Let me know if you try it and it does be interested to see. Awesome video too big ups.
You could've cache the amount moved so it's a bit faster and easier to understand. while (distanceTraveled < distance) { var movement = platformMoveDirection * MoveSpeed; transform.position += movement; distanceTraveled += platformMoveDirection.magnitude * MoveSpeed; for (int i = 0; i < AgentsOnPlatform.Count; i++) { AgentsOnPlatform[i].destination += movement; // for always aligned agents to platforms, you can use this but it will not allow the Agent to move while the platform is moving //AgentsOnPlatform[i].Warp(AgentsOnPlatform[i].transform.position + movement); } yield return null; }
I arrived a little late this time, but I couldn't miss a video from the AI series. A question, is it possible to make Unit NavMeshAgents navigate through more complex 3d meshes like trees for example?
I think so. I haven't actually tried it but I imagine because NavMeshes relatively planar... if you have a tree, the way I would approach that is to have a 90 degree rotated NavMesh to have the Agent be able to walk up the trunk, then another horizontal NavMesh from the branches you'd like the Agent to walk on. Connect these with some NavMeshLinks and it could probably work. That's a good one for me to experiment with though! Thanks for the idea!
thanks for the help and tips, until then i thought it was impossible to do this in Unity, even when i created a gigantic tree the result was not interesting.
At 6:54 in the video you add the distance traveled to distance instead of to distanceTraveled so the platform never stops moving in the direction of the first point. A small bug but an important one.
Wow! Thank you for catching that and calling it out! That is a very important one.
I double checked the GitHub repository and it looks like this was an error in the video, but in the repository it is correctly incrementing distanceTraveled. Anyone following along will need to be warned of this, and anyone who is copying scripts from GitHub will have it working correctly.
This is actually epic, imagine seeing Unity saying that this is not supported and then you make it happen and the limitations are also not really that big of a deal.
Great job honestly.
Thank you! I was really surprised to find that you could achieve this with relative ease! The drawbacks...depending on your game type may be a deal breaker but there are lots of use cases that they are really inconsequential
Oh God! I am cant belive that there are this way! I am try implement this in my game. Subscribed!)
Awesome! 😎
Hi I tried to apply this to a moving elevator, but when I update the surface position some agents get stuck mid air, the surface update happen every frame but the agent update don’t(asynchronous), can it be the reason why they lose the surface position ?
Hi. Thank you for this tutorial but where did you get the 'NavMesh Surface' component because it’s not showing up on my unity? Thank you
Hi! You need to use the NavMesh Components (github.com/Unity-Technologies/NavMeshComponents) to get the NavMeshSurface. In the first video of the AI series I go over how to install it: ruclips.net/video/aHFSDcEQuzQ/видео.html
Unity docs: you can't do that!
Llama man: hold my beer and watch this.
🤣
Enabale and dilsable agent it good idea to swap betwen navMeshes. Thanks
Hi, great videos!
What if you want to move to a normalized speed from one platform to another ? I mean avoid to move in a higher speed when pass thro the NavMeshLink ? Thanks!
Good question! I've covered NavMeshLink traversal on a couple of other videos. The simple one was: ruclips.net/video/dpJUc_BpChw/видео.html (AI Series Part 2) and a more advanced one here: ruclips.net/video/PD6VFD1a21g/видео.html (AI Series Part 17).
To shortly answer your question - you have full control over the agent while it traverses the NavMeshLink. You can calculate the distance they'll travel from the start/end points and move them over that distance using the Agent's current velocity, or target speed.
uhm........ I dont have "Collect Objects" in my NavMeshSurface component. Unity ver.2022.2.21f
🤔docs.unity3d.com/Packages/com.unity.ai.navigation@1.1/api/Unity.AI.Navigation.NavMeshSurface.html#Unity_AI_Navigation_NavMeshSurface_collectObjects
It seems like it should be there. This has always been an option on the Surface. Can you maybe reinstall your Navigation Components and see maybe something went wrong in the installation?
How did you get navmesh surface script in 2022? It doesn't pop up for me
You have to install the navigation package from the package manager
Moving platforms are fun. Have you tried rotating platforms?
I have not. I imagine you'd do the exact same thing, but instead of updating the destination every frame, you would update the Agent's local rotation every frame by the same amount as the platform is rotating.
I'll take a look and see if it's that simple and get back to you.
@@LlamAcademy kinda, you still have to move the player/agent.
Say like a short and wide column that is rotating; The rotation and distance of the column has to be translated to the player's position and rotation.
True. I'll let you know, possibly with a follow up video
@@LlamAcademy has this been addressed?
@@danielcrandall2033 don't tell anyone, but that's next week's video 😉
How could this work when teleporting an entire navmeshsurface? Is it possible to do so without rebuilding that navmeshaurface and simply warp the ai?
Hmm... I think rebuilding the NavMesh would be the safest option for that.
Depending on how far you're "Teleporting" you could just have 2 instances of whatever your player is on and have the teleport just warp the player between the two.
Thanks for this. Would this be applicable to platforms that just move up and down? Or is a different way recommended?
Great question! As long as the platforms don’t move too quickly I see no reason they won’t work for up/down movement as well. I haven’t tried that myself yet but based on how it works, I don’t expect any issues with that
@@LlamAcademy Ok, great! I will give it a shot. I see that you’re covering a ton of super useful topics(enemy surround, ai door behavior, hitscan tracers etc.) Can’t wait to dig into them. Subscribed!
Good tutorial!
Thank you!
Would you say it is possible to use off-mesh links when navigating using joystick/wasd movement?
I'm not entirely sure. I would not try to mix the NavMesh with Joystick / WASD movement. Instead, I would control it with a Character Controller or Rigidbody Controller and implement a jump. Any "Enemies" could be on a NavMesh to chase the player. That's how I implemented it on Llama Survival at least - the player runs around on the level with a Character Controller and all the zombies use the NavMesh with some NavMeshLinks to jump over gaps / obstacles.
Really good series.Is it possible to make it so that when enemies spawn the kind of roam around the spawn area?
Yes! That's covered in AI Series Part 11 ruclips.net/video/3hXkdARwREo/видео.html
@@LlamAcademy Thank you ,much appreciated.
You're welcome!
Need to test it but could just when the agent goes onto the platform child the agent with the platform. Think potentially solve alot of the other limitations as the agent could you the local position then to move around on the platform movement speed would remain relevant because of be a child of the other agent I may be not calculating for something but I am positive that will work. Let me know if you try it and it does be interested to see. Awesome video too big ups.
I'll definitely try it out alongside the rotating platform to see how it goes! Thanks for the idea!
@@LlamAcademy very welcome came to channel needing prototype quick AI for game releasing at pocket gamer connect 8. So thank you for the content.
I dropped you an email hope I addressed it correctly.
You could've cache the amount moved so it's a bit faster and easier to understand.
while (distanceTraveled < distance)
{
var movement = platformMoveDirection * MoveSpeed;
transform.position += movement;
distanceTraveled += platformMoveDirection.magnitude * MoveSpeed;
for (int i = 0; i < AgentsOnPlatform.Count; i++)
{
AgentsOnPlatform[i].destination += movement;
// for always aligned agents to platforms, you can use this but it will not allow the Agent to move while the platform is moving
//AgentsOnPlatform[i].Warp(AgentsOnPlatform[i].transform.position + movement);
}
yield return null;
}
Thanks for the improvement!
I arrived a little late this time, but I couldn't miss a video from the AI series. A question, is it possible to make Unit NavMeshAgents navigate through more complex 3d meshes like trees for example?
I think so. I haven't actually tried it but I imagine because NavMeshes relatively planar... if you have a tree, the way I would approach that is to have a 90 degree rotated NavMesh to have the Agent be able to walk up the trunk, then another horizontal NavMesh from the branches you'd like the Agent to walk on. Connect these with some NavMeshLinks and it could probably work.
That's a good one for me to experiment with though! Thanks for the idea!
thanks for the help and tips, until then i thought it was impossible to do this in Unity, even when i created a gigantic tree the result was not interesting.
amazing
Thank you! This one was a fun one for sure.
WTB llamacademy shirt. ty
I'll see how I can make that a reality!
Yay
That was my reaction too! 😁
sad that unity can't have true moving platform