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
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?
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.
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.
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 🎉
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.
@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 ❤❤❤
@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🙄
@@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.
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
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
Thanks a lot!
I was just searching how granny comes over to the place where player makes sounds and found your video
Same
I really liked this one. Thank you 🙂
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?
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.
Great Video
Great comment.
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
]
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.
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 🎉
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.
@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 ❤❤❤
@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🙄
@@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.
@FeedMyKids1 awesome logic, now I understand how this work, you genius I like this tutorial, you very help me 🙏❤🌌🖐👽
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
hi
Hello!
Hi😅
@@66ogg 😶
@kumatoons5508 😭