How to Make NPCs/AI Respond to Sound (How to confuse enemies like in FarCry)

  Рет қаралды 8,154

Feed My Kids

Feed My Kids

Күн бұрын

Пікірлер: 25
@Wolfwuf
@Wolfwuf 8 ай бұрын
This is how tutorials should be, i love how you dig through scalability and the design choices. Simple, scalable and not over engineered. Perfect thanks sir
@FeedMyKids1
@FeedMyKids1 8 ай бұрын
Thanks a lot!
@Ryan-mf4pd
@Ryan-mf4pd 4 күн бұрын
Super useful and I really like your style of tutorial
@castlecodersltd
@castlecodersltd 6 ай бұрын
I really liked this one. Thank you 🙂
@fandtm8054
@fandtm8054 2 жыл бұрын
I was just searching how granny comes over to the place where player makes sounds and found your video
@buntygamer5250
@buntygamer5250 3 ай бұрын
Same
@66ogg
@66ogg 2 ай бұрын
Hello bro, please ask me how work calling to Sound class from another classes, you not use static instance and you not add public or serialized field on top of head script, how this work? 😮😅 I'm new in unity 9:00 🎉
@FeedMyKids1
@FeedMyKids1 2 ай бұрын
Hey, Sound is in the GamePlay namespace, so you can either make a Sound instance by calling something like (say a rock collided with the ground and you want the sound to "happen" at that point, you'd use the rock's position, a sound radius for a rock [say a rock hitting concrete carries farther than an impact on grass], and pass the type of sound [optionally]): "GamePlay.Sound sound = new GamePlay.Sound(rock.transform.position, rock.GetComponent().soundRadius, SoundType.Interesting);" At the top of your script file you could use the "using" keyword to bring in the GamePlay namespace or encapsulate your class in the GamePlay namespace to avoid the GamePlay.Sound call and just call Sound.
@66ogg
@66ogg 2 ай бұрын
@FeedMyKids1 thanks for answer ❤ rocks. GetComp.soundRadius ( it's can be script on rock object? I right understand, I use u code, this awesome mechanic ❤❤❤
@66ogg
@66ogg 2 ай бұрын
@FeedMyKids1 and one more stupid question bro, respond to sound in npc behavior execution is not update just function, it's work because using Gameplay namespace, or this hide internal functions csharp? 😭 I'm really stupid🙄
@FeedMyKids1
@FeedMyKids1 2 ай бұрын
​@@66ogg Here's what the call stack would look like: Rock hits ground. Calls -> Create Sound -> Sounds.MakeSound(pass the sound just created) Sounds.MakeSound checks for any IHear objects nearby. If there are any, for each one it calls -> IHear.RespondToSound(passes the sound from before). IHear/Child Class, 'npc behaviour', -> gets its RespondToSound implementation called and that's where the action happens. Everyone is "stupid" when they start. The truly stupid are those who never begin.
@66ogg
@66ogg 2 ай бұрын
@FeedMyKids1 awesome logic, now I understand how this work, you genius I like this tutorial, you very help me 🙏❤🌌🖐👽
@banditbloodwyndevs8782
@banditbloodwyndevs8782 Жыл бұрын
As far as I understand this you implemented a variant of an Event bus for this, right? It's a good idea. My question now: The sound propagation here works via an OverlapSphere and a direct distance value, so the sound travels linearly. What if the sound has to travel through rooms? Or what if there are walls between the sound source and the AI agent?
@KampinKarl1
@KampinKarl1 Жыл бұрын
To the extent that IHears are event listeners and an NPC deciding what is more important (the sound or whatever it was doing before), yes; it’s an event bus. Good questions. These are pretty basic tutorials because the lower level the audience, the more people the video generally appeals to, so I don’t even get into cases of being in a room or sound occlusion. Normally what a dev team will do in a room based scene (or for example in COD Warzone) is have a sound map for propagation (and in the case of call of duty, whether a gunshot will have a tail sound). A simple map would have a room and a list of connected rooms. The connected rooms might hear the sound and if they do, possibly tell the listener the originating room. In the case of walls: you might do the overlap sphere to check what could potentially hear the sound then do a raycast to check for occlusion. Say you have an obstacle like a wall between the listener and sound maker, you could say that the obstacle has a sound dampening effect and throws the sound to the closest edge of the wall. As far as linear distance: you can definitely make the AI seem more realistic by sending them to kind of wander in the vicinity of where they think the sound came from. So say the sound came from far away, you send the NPC to a random spot in the direction from which the sound came. Hope this helps.
@zachthenebula
@zachthenebula 2 жыл бұрын
Great Video
@FeedMyKids1
@FeedMyKids1 2 жыл бұрын
Great comment.
@jinitdave
@jinitdave Жыл бұрын
I love the video, but I have a problem - my AI is not reacting to the stone when the stone is thrown, My script is same as yours [Please Help ]
@FeedMyKids1
@FeedMyKids1 Жыл бұрын
If you mean that you want the AI to react to the sound you make when you literally throw it (release it from the hand), just call Sounds.MakeSound and pass in a new Sound with your position and the range over which the sound can be heard. If you mean the AI doesn't respond when the stone collides with the floor: Make sure that your stone has a script calling OnCollisionEnter in the body of which it calls Sounds.MakeSound and creates a new sound. Hey, sorry I didn't get back to you sooner. I really do have kids so sometimes it takes a while.
@FeedMyKids1
@FeedMyKids1 2 жыл бұрын
Sorry, I can't put a link directly into the video via Cards so here's the link for the GitHub repo which includes the scene file and stuff for throwing rocks: github.com/KampinKarl1/Unity-AI-Behaviours/tree/main/GamePlay
@kumatoons5508
@kumatoons5508 2 жыл бұрын
hi
@FeedMyKids1
@FeedMyKids1 2 жыл бұрын
Hello!
@66ogg
@66ogg 2 ай бұрын
Hi😅
@kumatoons5508
@kumatoons5508 2 ай бұрын
@@66ogg 😶
@66ogg
@66ogg 2 ай бұрын
@kumatoons5508 😭
How to Make NPCs/AI Run Away (with examples in Unity)
24:14
Feed My Kids
Рет қаралды 11 М.
How do non-euclidean games work? | Bitwise
14:19
DigiDigger
Рет қаралды 2,5 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
3 Hours vs. 3 Years of Blender
17:44
Isto Inc.
Рет қаралды 7 МЛН
20 Advanced Coding Tips For Big Unity Projects
22:23
Tesseract
Рет қаралды 213 М.
10 Minutes vs. 10 Years of Animation
19:29
Isto Inc.
Рет қаралды 1,5 МЛН
Creating the PERFECT Stream Game
11:33
Isto Inc.
Рет қаралды 200 М.
Which AI Behavior Framework Should You Use? | AI Series 46
17:26
LlamAcademy
Рет қаралды 54 М.
Horror Post Processing Profile in Unity
7:35
SpeedTutor
Рет қаралды 37 М.
ADD ARMS TO YOUR GAME - EASIEST WAY (Unity3D)
15:22
JonDevTutorials
Рет қаралды 69 М.
How to make AWESOME Scene Transitions in Unity!
19:45
Brackeys
Рет қаралды 974 М.
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН