How to make Line of Sight in Unity 2D with Raycast
In this Unity Tutorial we implementing a Line of Sight Script in Unity 2d using Raycast and Raycasting. Basically allowing the Player to hide behind Colliders and the Enemies to only follow if they have line of sight. This turns out to be quite easily done with Raycasts.
== LINKS ==
▶️ GitHub: github.com/Tutorials-By-Kaupe...
▶️ Starting Unity Package: url.kaupenjoe.net/gdbkj25/uni...
▶️ Unity Package: url.kaupenjoe.net/gdbkj26/uni...
▶️ Gist: url.kaupenjoe.net/gdbkj26/gist
== CREDITS ==
Character by: merchant-shade.itch.io/16x16-... by Merchant Shade under CC0
Tiles by: anokolisa.itch.io/dungeon-cra... by Anokolisa under CC0
Crab by camacebra.itch.io/crab-pixel-art by Camacebra under CC0
Bricks by bakudas.itch.io/generic-dunge... by Bakudas under CC0
== HASHTAGS ==
#kaupenjoe #unitytutorial #unity
Пікірлер: 13
Waiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiit ! Kaupenjoe ! I remember following your minecraft tutorials :')
Wow, this taught me so much in the span of just a few minutes. Thank you! Raycasting is gonna be super useful. I'm imagining it "should" work similarly in 3d probably. Hopefully...
@GameDevByKaupenjoe
10 ай бұрын
That's awesome to hear 😎💙 I am pretty sure the idea is exactly the same, just with that pesky added third dimension 🤣 Currently, I am not brave enough to venture into that, but maybe at some point 🙏🏻
very nice tutorial, helped me out a lot. i have a question to your unity, how can you see all of the "scene" stuff in your game view? you see the line of sight and the colliders and stuff like this.
back when i started unity, raycasts seemed very daunting because the syntax is so long, now it seems like second nature
@GameDevByKaupenjoe
10 ай бұрын
Ye, I can fully understand that. There can also be quite a few nuances to get right. But overall, they are really cool and pretty useful 😁
Thank you!
@GameDevByKaupenjoe
10 ай бұрын
Absolutely, had a blast making the tutorial. Turned out really cool 😁😁
Can you try to make this compatible with the ''A pathfinding'' project, because no matter how hard I try, I think I'm missing some things, can you please explain in detail how LOS would be compatible with this project, etc.? I won't say things like it's very watchable, but rest assured, I will watch the video until the end, even if it is 10 hours long. pls :'D
Is it possible to make it so that when the player is out of sight, the enemy would still run to the last seen position to look for the player?
Hey Kaupen! Could you make a simple AI that chases the player has lime of sight and when in range attacks the player (you can just make function Attack() or use comments in the video) in unity 3D with NavMeshAgent Great Video!
@GameDevByKaupenjoe
10 ай бұрын
Hey George, well I can definitely look into it - idk how fast I will be able to do something on this, but I have added it to my list of topics 🙏🏻🙏🏻
@georgekaragiozis3191
10 ай бұрын
@@GameDevByKaupenjoe Nice, thanks for responding.