Тёмный

Random AI Patrolling Tutorial Unity3D 

JonDevTutorials
Подписаться 1,1 тыс.
Просмотров 53 тыс.
50% 1

In this video I will teach you how to make a navmesh agent move around randomly within an area.
Code (yes you can use it for whatever you want): github.com/JonDevTutorial/Ran...

Опубликовано:

 

15 июл 2022

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 81   
@JulianSanchez-fk7ly
@JulianSanchez-fk7ly Год назад
I have been watching videos longer than 20 minutes. And literally the one that helped me was a 2 minute long video with memes.
@patrickalexander8066
@patrickalexander8066 Год назад
The sims build mode music is the cherry on top, beautiful!
@nikjeewon4672
@nikjeewon4672 Год назад
Thank you for this. Love the short and straight to the point ones :)
@madduckling4436
@madduckling4436 Год назад
I don't use Unity at the moment but I understand the logic behind some of the things you're teaching and I transfer what I learned to GDscript you deserve a sub you deserve a like and you deserve my attention for every video you upload.... one day when i reuse unity I'll be rewatching all of the videos aswell!
@jondevtutorials4787
@jondevtutorials4787 Год назад
Thanks beast, nice job on transferring the knowledge over to something else, it's a good skill to have.
@a3dadventure79
@a3dadventure79 11 месяцев назад
nice job - it's a really simple yet essential bit of ai coding. thanks for putting this up and keeping it simple. more of this = gold !
@inimagames
@inimagames 6 месяцев назад
Simple, but straightforward and very useful! Thanks a lot for the help! 💪
@angelkaki5707
@angelkaki5707 8 месяцев назад
Finally somebody who goes straight to the point even tho the script was in unity xD!!! now i guess its time to work on a way to have the enemy chase you and attack but if the player leaves the area after a certain distance the mob will go back to its original spot
@LordVilmore
@LordVilmore Год назад
so much value in such little time. impressive!! most tutorials would need 16 minutes for this... uggggggh
@nicholasnui6630
@nicholasnui6630 Год назад
Subscribing just for the upbeat music at a reasonable level in the background
@vannerss7287
@vannerss7287 Год назад
If you don't subscribe after watching such an eloquent tutorial, pls don't make games.
@davidgil1171
@davidgil1171 2 года назад
Thanks for this!!! I really lovethe format of your videos, just keep it up! Day 2 of asking for a simpler Inventory system btw
@jondevtutorials4787
@jondevtutorials4787 2 года назад
Sure, how about a weapon wheel as well?
@gyrostat5211
@gyrostat5211 Год назад
@@jondevtutorials4787 yes
@naosabes2589
@naosabes2589 Месяц назад
"It is legally required to like the video, you dont wanna end up like this guy" 😂😂😂😂😂😂
@unDeadGod69
@unDeadGod69 3 месяца назад
Really good tutorial, thanks for the help
@offsider_
@offsider_ Год назад
Easy to follow, informative and fucking funny had to subscribe!
@ricktherickrolled
@ricktherickrolled 7 дней назад
oh my god it was THAT easy!!! Thank you so much!!
@renaisol
@renaisol 6 месяцев назад
very useful! gonna save it for next project XD
@Cyberinfinitystudio
@Cyberinfinitystudio 27 дней назад
This is so good for my game thanks
@whitetiana3022
@whitetiana3022 Год назад
this reminds me of my time in uni. they didn't bother to explain anything either.
@junaidjamshed8104
@junaidjamshed8104 Год назад
Love it
@beshkekart3909
@beshkekart3909 Год назад
GEENIUSSS!!!!
@gyrostat5211
@gyrostat5211 Год назад
cool stuff dude
@dangboor4277
@dangboor4277 11 месяцев назад
Thanks my good sir
@thesaviorofsouls5210
@thesaviorofsouls5210 8 месяцев назад
Awesome, this helped me so damn much. Appreciate it, have a like as by contract ;P
@xrxsever
@xrxsever Год назад
tnx mate
@hirayukisei3813
@hirayukisei3813 5 месяцев назад
Thank you so much.
@marinavlachandreas5197
@marinavlachandreas5197 Год назад
It works :)
@cosminwheelz2597
@cosminwheelz2597 9 месяцев назад
Hello there! Is it mandatory to bake both the surfaces from the navmeshSurface component and also from the navMeshAgent?
@Dev_Roids
@Dev_Roids 7 месяцев назад
Thanks sooo much
@farziverse4209
@farziverse4209 10 месяцев назад
How do I give logic to the randomness. Such that the agent may run away from player in a random zig-zag manner
@leonbierling4857
@leonbierling4857 Год назад
How can I make the NPC fly up and down with this? (By setting layers of baked navmash for instance)
@BlueAndy_
@BlueAndy_ Год назад
thanks man
@kingawesomeness1239
@kingawesomeness1239 5 месяцев назад
thank you
@catbushi1756
@catbushi1756 9 месяцев назад
Where can I find the navmesh agent and what should I put in the boxes: "Agent, Range and Centre Point" ?
@wmka
@wmka Год назад
I'm thinking of making random movements for cockroaches. How do I make them move from floor to wall to ceiling? Thank you and have a good one
@jondevtutorials4787
@jondevtutorials4787 Год назад
You will probably want to create a custom navmesh, and make sure you orient the cockroaches to the normals of your surface. Here is a good video: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-bl9_bRZs0Gg.html&ab_channel=El-Capitan
@Kapra_crow
@Kapra_crow Год назад
Is there any way I could make so if the enemy detects the player it sets the player as the destination?
@zacharmy8948
@zacharmy8948 Год назад
What you could do is make a public Transform variable and set the player's transform to that variable. If you are going for an automatic range detect system, you can get the distance between the player and the NavMeshAgent by using Vector3.Distance() and pass in the two arguments. Then you can create a float variable which will determine the detection range. Next, you can use an if statement to check whether the distance between the AI and the player is less than the range variable. If the player is in range you can call the NavMeshAgents's SetDestination() function and pass the player's position as an argument.
@jasonwilliams8730
@jasonwilliams8730 Год назад
Like👍
@FakeMrFlimFlam
@FakeMrFlimFlam Год назад
Hello, thanks for this tutorial. But what do you put in Centre Point ? Thanks
@jondevtutorials4787
@jondevtutorials4787 Год назад
Just create an empty gameobject and use that. Position the empty gameobject on the floor of the navmesh.
@Airelon
@Airelon Год назад
Obligation fulfilled🤪
@SamPlayz9716
@SamPlayz9716 Год назад
what do i set for centre point
@jaydaykoth
@jaydaykoth 4 месяца назад
Does anyone have any ideas on how to play walking animations for humanoid npcs
@user-dw6es7zg8z
@user-dw6es7zg8z 2 месяца назад
Danke
@grkpektis
@grkpektis Год назад
Please help, he just stops at the middle
@saltyyy5765
@saltyyy5765 2 дня назад
You ever find a fix?
@user-ly2zr3hr3v
@user-ly2zr3hr3v 4 месяца назад
what do i do with the navmesh? i somehow cant get it to work
@foxys891
@foxys891 Месяц назад
he dosent move for me or just me being dumb it was helpfull but dosent walk for me maybe im just missing some thing cause i just threw in the script the navmesh baked it and still doset move
@jarrydoneill7834
@jarrydoneill7834 Год назад
How could I implement this in 2D?
@cxd1
@cxd1 Год назад
Can you make something like this but with a car ?
@vinnythehusky3481
@vinnythehusky3481 13 дней назад
Question does anyone know how to make it work on VRCHAT?
@dertobbe1176
@dertobbe1176 Год назад
My agent get stuck at destination point. He wont finish the path
@vladaslittleparadise4402
@vladaslittleparadise4402 Год назад
im having a problem... so it works at the start... but i notiched that after following the first waypont it stops moving ... so i started looking at it in the editor view and only a waypoint apperars... after that the agent just spins (int the script component i put the agent im using, for the Range value i put 20 and for the Centre point i put the floor im using)
@jondevtutorials4787
@jondevtutorials4787 Год назад
If you copied the code exactly from the GitHub it may be a problem with your NavMeshAgent component. For example, the navmeshagent stopping distance could be too large. Or maybe it's a problem with the navmesh not being baked properly.
@vladaslittleparadise4402
@vladaslittleparadise4402 Год назад
@@jondevtutorials4787 i managed to fix the problem... thank you very much
@se5d
@se5d Год назад
@@vladaslittleparadise4402 i`m having the same problem.. what did you change?
@vladaslittleparadise4402
@vladaslittleparadise4402 Год назад
@@se5d nothing really... I just re-did it
@bluntbangs
@bluntbangs 9 месяцев назад
@@jondevtutorials4787 Just to clarify as someone who had the same issue, you have to set the "Range" above 0, or else the agent will just move straight toward the centre point.
@StucWf
@StucWf Год назад
I'm definitely doing something wrong. I applied the script to a capsule but nothings happening
@jondevtutorials4787
@jondevtutorials4787 Год назад
Did you bake a navmesh?
@StucWf
@StucWf Год назад
@@jondevtutorials4787 Yes, the floor was blue
@rasulkhani
@rasulkhani 7 месяцев назад
I added an empty game object and put it as the center point but the AI just moves to the center point and stops, is there anyway I can fix this?
@miquelsunyerroda9638
@miquelsunyerroda9638 5 месяцев назад
have you implemented a navmesh surface? bool RandomPoint(Vector3 center, float range, out Vector3 result) { Vector3 randomPoint = center + Random.insideUnitSphere * range; // Punto aleatorio en una esfera NavMeshHit hit; if (NavMesh.SamplePosition(randomPoint, out hit, 1.0f, NavMesh.AllAreas)) { result = hit.position; Debug.Log("Random Point: " + result); // Mensaje de depuración con las coordenadas del punto return true; } result = Vector3.zero; Debug.Log("SEARCH FOR POINT FAILED"); // Mensaje de depuración si la búsqueda del punto falla return false; } Change the Bool for this one, it will print on the console if there is a point found or not and the position of the random generated point
@rasulkhani
@rasulkhani 5 месяцев назад
@@miquelsunyerroda9638 ok thx it works now
@spai_wolf8561
@spai_wolf8561 Год назад
Hello brother can we reduce the stoping time between the points?
@jondevtutorials4787
@jondevtutorials4787 Год назад
Hello brother, Play with your navmeshagent settings in the inspector. Try increasing acceleration, disabling autobreaking etc. Best of luck
@spai_wolf8561
@spai_wolf8561 Год назад
@@jondevtutorials4787 i will try and see
@michaelmalard8145
@michaelmalard8145 8 месяцев назад
​@@spai_wolf8561 Did it works? And what did you change ??
@reedwitch9246
@reedwitch9246 Месяц назад
I don't think this will help, since you wrote the comment a long time ago, but maybe it will help someone else who will continue to use this tutorial! private float nextActionTime = 0.0f; public float period = 0.1f; void Update() { if (Time.time > nextActionTime) { nextActionTime += period; //part of the original script begins if (agent.remainingDistance
@akamaraasho
@akamaraasho Год назад
How can I make it work in a 2D game?
@studioshitaketakashita7093
@studioshitaketakashita7093 11 месяцев назад
you use vector 4's - and then divide by two
@Hunter-X9211
@Hunter-X9211 Месяц назад
At least explain the code properly that what will be the values and how can we stop agent when he reached the point he just run here and there
@jackmarquette1351
@jackmarquette1351 Год назад
I can’t read
@julianrockl4228
@julianrockl4228 Год назад
Too lazy for waypoints it is.
@foreignwarren7361
@foreignwarren7361 Год назад
Can this work for 2D?
@supersentaimexicano1967
@supersentaimexicano1967 Год назад
Is there a way to visualize the Range that the MOnster have ?
@jondevtutorials4787
@jondevtutorials4787 Год назад
Yes you can use Gizmos
Далее
How to ACTUALLY get into Gamedev
14:01
Просмотров 704 тыс.
Dear Game Developers, Stop Messing This Up!
22:19
Просмотров 696 тыс.
Она Может Остановить Дождь 😱
00:20
How to Pick Up + Hold Objects in Unity (FPS)
3:42
Просмотров 23 тыс.
Using Image Recognition to DESTROY Fruit Ninja
10:08
Просмотров 603 тыс.
Patrolling AI in Unity with C#
5:34
Просмотров 32 тыс.
Unity NavMesh Tutorial - Making it Dynamic
9:00
Просмотров 361 тыс.
Enemy Patrolling Unity Tutorial
8:28
Просмотров 8 тыс.
A new way to generate worlds (stitched WFC)
10:51
Просмотров 518 тыс.