Тёмный

Field of View Effect in Unity (Line of Sight, View Cone) 

Code Monkey
Подписаться 534 тыс.
Просмотров 151 тыс.
50% 1

✅ Get the Project files and Utilities at unitycodemonkey.com/video.php...
Let's make an awesome Line of Sight effect that interacts with walls, enemies outside the Field of View are not visible. Excellent effect for any sort of Stealth or Horror game.
Get Survivor Squad and Survivor Squad: Gauntlets in the Game Bundle
unitycodemonkey.com/gameBundl...
Make Awesome Effects with Meshes in Unity | How to make a Mesh
• How to make a Mesh in ...
Unity Layers, Layer Mask, Bitmask, Bitwise Operators, Raycasts
• Unity Layers, Layer Ma...
If you have any questions post them in the comments and I'll do my best to answer them.
🔔 Subscribe for more Unity Tutorials / @codemonkeyunity
See you next time!
🤖 Join the Community Discord / discord
📦 Grab the game bundle at unitycodemonkey.com/gameBundl...
📝 Get the Code Monkey Utilities at unitycodemonkey.com/utils.php
#unitytutorial #unity3d #unity2d
--------------------------------------------------------------------
Hello and welcome, I am your Code Monkey and here you will learn everything about Game Development in Unity 2D using C#.
I've been developing games for several years with 7 published games on Steam and now I'm sharing my knowledge to help you on your own game development journey.
You can see my games at www.endlessloopstudios.com
--------------------------------------------------------------------
- Website: unitycodemonkey.com/
- Twitter: / unitycodemonkey
- Facebook: / unitycodemonkey

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

 

4 авг 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 588   
@CodeMonkeyUnity
@CodeMonkeyUnity 4 года назад
See this effect in action in Survivor Squad and Survivor Squad: Gauntlets Get the Game Bundle at unitycodemonkey.com/gameBundle.php See what I'm teaching here applied to real games!
@EliteHumanNetwork
@EliteHumanNetwork 4 года назад
Are you proficient with HTML 5 game developed?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 года назад
@@EliteHumanNetwork Nope never tried out HTML 5. I jumped from Flash straight into Unity.
@RM-lw2qi
@RM-lw2qi 4 года назад
In the game you are showing at 1:18 the light is much smoother than the one we create in this video. Could you elaborate on how you created that smoother effect without hard edges? Really great tutorials btw!
@CodeMonkeyUnity
@CodeMonkeyUnity 4 года назад
​@@RM-lw2qi The effect in the game is actually done using a different method. Each Survivor has a camera pointing to where they can see, then the depth from that camera is used combined with the main camera to then generate the effect with a shader. The reason why that effect works in there is because that game is 2D but all the Walls and Doors are 3D objects, that method doesn't work in a pure 2D game. However with this method you could create a 2D shader to achieve a similar result.
@PatrickNusbaum
@PatrickNusbaum 4 года назад
@@CodeMonkeyUnity Would you mind giving a hint on how to create such a shader?
@francoiskrugerpersonal2985
@francoiskrugerpersonal2985 2 года назад
From 18:27 you can't really follow the video anymore :( But here are updated steps: 1) Open Windows > Package Manager & install Universal RP 2) Create a "Rendering > URP Asset (with 2D Renderer)" 3) "New Universal Render Pipeline Asset" is your "LightweightRenderPipelineAsset" and "New Universal Render Pipeline Asset_Renderer" is your "CustomForwardRendererData". I added these names in () to easily follow the video. 4) Go "Edit > Project Settings" and on the "Graphics" tab drag in your LightweightRenderPipelineAsset 5) On the CustomForwardRendererData go "Add Renderer Feature > Render Objects" 3 times and set your settings like Mask, BehindMask and Black in the video That said, I'm still battling to get the stuff working like in the video. Code Monkey or anyone else would you be able to reply with the missing steps I can't get right? It feels to me that the settings in each of the Render Features need to be a little different to your video? Also, I don't know where the "CustomForwardRendererData > Default Layer Mask" setting is anymore?
@billycombo8298
@billycombo8298 2 года назад
If you download the package for this project, you can imporant the URP files and they work perfectly, you'll just need to change the layers around if you don't have your layers set up the same way he has
@fyodorzaletov3237
@fyodorzaletov3237 Год назад
Hi. I don't think you need any more help, but it might help others. In general, you need to make not a Renderer Pipeline 2D, but a Universal Renderer, which will have Filtering settings. after playing with them and adjusting the layers, you will finally be able to achieve the desired result!
@husdf_
@husdf_ 5 месяцев назад
This help a lot, thank you very much@@fyodorzaletov3237
@KOLHO
@KOLHO Месяц назад
If anyone has any problems after minute 18:27, just download and install the Universal RP package and continue configuring it, as shown in the video. => Open Windows > Package Manager & install Universal RP Note: make sure that the layers are configured correctly, as shown in the video.
@StixxyTape
@StixxyTape Год назад
For anyone who was really stuck like me: if the Field of View isn't showing up after setting its layer to mask, then check the material. Make sure it's surface type is set to transparent and not opaque. Worked for me after a bunch of trial and error, so I hope it works for you too! :D
@Emicenizo
@Emicenizo Год назад
FYI: The combination that worked for me on URP is: Opaque Layer Mask: Default, TransparentFX, Ignore Raycast, Water, UI Transparent Layer Mask: Default, TransparentFX, Ignore Raycast, Water, UI, Objects, Black Also, if you are importing CM's files, keep in mind that the Render Steps on the CustomForwardRenderData may not have the correct Layer Mask by associated (check that on each). Finally, I added the CustomForwardRenderData asset to both the Graphics and Quality menus on Edit > Project Settings > Graphics and > Project Settings > Quality.
@DridgeDEU
@DridgeDEU 2 месяца назад
I felt like I HAD TO wrote how amazing this script is and also thought perhaps others could also benefit from how I learned from this video. After watching the tutorial and following along, I tried to do the same thing again and to do my own script to create this custom mesh. This turned out to be a gigantic task which took me around six hours, and I didn't even get all the things done like defining the angle, having a different starting position and view orientation etc. But that way I really honed the idea of creating custom meshes in code, especially such a complicated one like areas of a circle like you do here. I'm actually a programmer by trade but doing all these mathematical calculations is quite something else; kudos to you that this seems so easy to you and that you even share it with the whole community. I love about your script how versatile it is with the different parameters on top. Truly impressive.
@StixxyTape
@StixxyTape Год назад
2nd tip for anyone who was stuck like me: If the field of view disappears when the game object goes out of the camera's view, try putting this line of code mesh.RecalculateBounds(); after setting the mesh.vertices/uv/triangles stuff, like this: mesh.vertices = vertices; mesh.uv = uv; mesh.triangles = triangles; mesh.RecalculateBounds();
@user-oj3bd2ow8o
@user-oj3bd2ow8o Год назад
thank you. I think I've been struggling with this problem for a week. I am infinitely grateful to you.
@kazoomonster237
@kazoomonster237 Год назад
gud fish
@jarrettonions3392
@jarrettonions3392 9 месяцев назад
Wow... i dont know how long it would have taken.. thank you
@deliriousmansano3556
@deliriousmansano3556 4 года назад
I will watch your videos on June after we graduated because we do lot of things now til march. I started learning the basic of unity, the UI, animation. And when I graduated I will learn how to make 2d games.
@jseneque
@jseneque 4 года назад
Again a very informative tutorial. Thank you
@soco5338
@soco5338 2 года назад
Thing about your videos that I really love is that when you type, I have to slow down the video speed to .25f and to hear what you're saying I need to speed it back up to normal. It's a very fun game to play while trying to learn what you're teaching.
@CodeMonkeyUnity
@CodeMonkeyUnity 2 года назад
Always remember that you're not expected to be able to completely follow and implement a tutorial in the time that the video takes. When you see a 20 minute tutorial it absolutely did NOT take me 20 minutes to learn all this and build it. A simple 20 minute tutorial has hours or days not to mention my 20 years of programming experience behind it, so you're not expected to follow along in real-time.
@cristiano4826
@cristiano4826 4 года назад
Great as always👌
@jean-michel.houbre
@jean-michel.houbre 3 года назад
An excellent video, which RU-vid forgot to notify me.
@catplays1137
@catplays1137 4 года назад
Reminds me of a game called NOX..nice work dude :)
@dash-t5489
@dash-t5489 6 месяцев назад
If anyone has problems with the outdated last part of the video, another alternative you can use is: ·Create a function to check if a point is inside of the mesh using mesh.bounds.Containts(Vector3 point) ·If it's inside you enable the visual, if not, don't Personally I used a singleton pattern in the player's fov to have the function on any object I needed to toggle the visual. Once again thanks CodeMonkey for such a great content!
@JJFiapoko
@JJFiapoko 2 месяца назад
Hey @dash-t5489, I was hoping you could share your code for that. I am pretty new and completely lost on the last part of the video. I would love to see what you ended up doing instead in more detail. If you have the opportunity to share it. Or just screenshot or screen record the process.
@ZirixNightcore
@ZirixNightcore 4 года назад
You do some nice work, good job
@CodeMonkeyUnity
@CodeMonkeyUnity 4 года назад
Thanks!
@TheJamnikER
@TheJamnikER 3 года назад
THANKS! Very helpfull tutorial
@hakanviajando
@hakanviajando 3 года назад
Thank you very much for your videos. Scriptable Render Pipeline part was very interesting but it's really difficult to understand for people who don't know about buffers, stencil etc. I hope you do some in-depth tutorials about SRP. I would be happy if anyone who sees this message recommends other resources to learn about it.
@namthangnguyen8514
@namthangnguyen8514 3 года назад
Thank you for greate tutorial.
@garethlynch2823
@garethlynch2823 2 года назад
Is there any way you can create this effect without using LRP? or other render pipelines other than built-in? I'm currently using a package that relies heavily on the old Post Processing V2 and fixing everything after changing over is a nightmare. Perhaps I'm overthinking this?
@ancalagon1144
@ancalagon1144 4 года назад
For anyone else having problems with the angle of the fov in relation to your aim being wrong: Try writing + fov / 2f; Instead of - fov / 2f;
@Virtualangello
@Virtualangello 3 года назад
Thank you good sir/madam. I was looking for this solution
@DerAbsender
@DerAbsender 3 года назад
Thank you, I was this close to replacing that part with a few if statements.
@user-oj3bd2ow8o
@user-oj3bd2ow8o Год назад
Thank god...
@vima9046
@vima9046 Год назад
Hello CodeMonkey! There are a couple of things i don't understand very well is this video. The first concerns the render pipeline(18:35). I don't understand very well what you are doing since i dont know much on RP. So, if i got it, based on how you order the layers in the settings it gives priority to one layer over another, am i right? This confuse me because you said that the RP is not rendering the layers that you remove from the list but actually we can see them on playmode. Do you have any advice in order to become more confident with these RP settings? The second is about the mesh bounds. Why the player don't draw the FOV at certain distances?
@adeled8833
@adeled8833 2 года назад
thank you so much for your channel
@francoiskrugerpersonal2985
@francoiskrugerpersonal2985 2 года назад
I battled a lot to get my field of view to interact with the walls. My problem ended up being that my FieldOfView game object had a 0.5 scale to it, which made the rays smaller (barely visible). In case this ever helps anyone :)...THANKS FOR ALL YOUR WORK CODE MONKEY! REALLY APPRECIATE IT!!!
@tylermiller1606
@tylermiller1606 4 года назад
Oh damn, survivor squad was this guy lets goooo
@MrBusinessDragon
@MrBusinessDragon 3 года назад
Hello! Overall great tutorial! I am having some issues with getting the URP to work with the layer masking though. I have all my layers set up right. It seems to not work? I could be missing something There are 2 layer mask options as well. do i use both or only one?
@FluidicClient
@FluidicClient 4 года назад
Would be nice if you could make a version of this for unity 19.3 as the URP does not work in the same way.
@lucasteles42
@lucasteles42 2 года назад
Yes, we need this 😅
@adventureman6997
@adventureman6997 6 месяцев назад
yes
@matthewventures
@matthewventures 4 года назад
Important step missing! After you setup the Lightweight Render Pipeline Setting you must set your Project Settings-> Graphics -> Scriptable Pipeline Settings to use it! ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-YAOin1eqcFc.html
@redoctober2088
@redoctober2088 2 года назад
Hey. I've had many problems with URP so i've decided to try with sprite masks instead - can I somehow pass the Mesh Filter as a sprite to Sprite mask sprite reference?
@castlecodersltd
@castlecodersltd Год назад
Very enjoyable
@xavmanisdabestest
@xavmanisdabestest 4 года назад
Amazing tutorial as always code monkey
@ancalagon1144
@ancalagon1144 4 года назад
I don't get the render pipeline part. I downloaded the utilities but the mask material is an error and what scripts should I give the lightweight render pipeline and the customforwardrenderer?
@xiaoyou9412
@xiaoyou9412 4 года назад
Mr.Monkey, I'm following your lesson to create a Conical, It's awesome! But I have created a TIlemap before and now the tilemap has coverd my Mesh Grid , so how can I do to make the Mesh Grid up to tilemap layer?
@calvinms7503
@calvinms7503 10 месяцев назад
Hey CM, I have used you CustomFOrwardRenderData but using this making me cannot use the 2D Rendered Data. As a result I cannot use 2D light. Any suggestion?
@1166miki
@1166miki 3 года назад
Hi! Could you add the scripts of the ForwardRenderer? I feel like the first part of the tutorial was way easier than the end. Thanks anyway!
@Sovereing2027
@Sovereing2027 Год назад
Good, thx
@anthonyortiz7924
@anthonyortiz7924 3 года назад
@CodeMonkey, this is a really great tutorial on 2D LOS and fog of war, you really break it down into steps that make it really easy to understand, thank you! The downloadable project files no longer work in the latest versions of Unity due to their rendering pipeline update; are you planning on updating this (and other) tutorials? Many thanks, liked and subscribed!
@Tiparium_NMF
@Tiparium_NMF 3 года назад
I'm doing a similar concept to this for a class project, but I want any object outside of the field of view to leave a sprite behind representing the last known location. Any suggestions?
@nyncrogmr
@nyncrogmr 3 года назад
Hello and thanks for the video I think it's great. I have a problem though, it seems to bee the object interaction part, it never detects any object. I'm currently using the 2019.4 version. I noticed that your Rendering Mesh has a field to chose a layer inside the additional settings box, mine doesn't, could that be the problem? Or maybe the type of object that I'm using as an obstacle?
@darksideskyy
@darksideskyy 3 года назад
how did you do literally any of the prep work for the rendering stuff after 18:30? i was following along and then i couldn't do anything else because even your FoV package's rendering stuff wont work because its missing scripts...
@Bladeshifter20
@Bladeshifter20 3 года назад
Part of the issue He has LWRP installed but I dont think he ever has you get it through package manager. Aside from that, LWRP no longer exists and is not Universal Rendering Pipeline. It the comment above I explained how to get through some of these issues.
@elektra81516
@elektra81516 3 года назад
Install Universal Render Pipeline
@1166miki
@1166miki 3 года назад
@@elektra81516 Where can i find that? i can't find it neither in the asset store or the package manager. Thank you
@1166miki
@1166miki 3 года назад
nvm, the issue was that the project was in the latest beta
@timeofjustice4094
@timeofjustice4094 3 года назад
When I follow all the steps, I got the problem that the RP ignores the sorting layers of my Sprites and always put the Sprite, with the Layer BehindMask, in front? Does anyone have an idea how to fix it?
@karllauer3173
@karllauer3173 3 года назад
Can this be extended to a gridless movement range indicator similar to xcom? I guess the biggest problem is, if an obstacle is entirely encompassed by valid range: that would mean having a polygon with a cut hole for the obstacle. any ideas?
@agtechart
@agtechart 3 года назад
Hi! First of all, ty for this tutorial! Could you make a tutorial about the Scriptable Render Pipeline??
@narutobutthole
@narutobutthole 3 года назад
Hello Code Monkey. I'm having a problem with this code. First I made a grid and when I place my player on said grid the FOV doesn't show up, as in the mesh I made to show the FOV doesn't appear on top of the grid. If I pause the game and click on the FOV in the hierarchy it shows the outline though. However if I take him off the grid it shows up just fine and will work as in intended with the corners of the grid. Thank you for your time.
@albertozp
@albertozp 3 года назад
Fantastic tutorials! I got it going on, although the FOV is mirrored from the cursor's position, and it is only showing triangles drawn with the origin and the vertices created by collisions (vertex at max distance aren't showing somehow). Anyone got any idea on what to check?
@MrOfearos
@MrOfearos 3 года назад
Hey there! Great tutorial! I wanted to ask you how you would go about turning this line of sight into a collidable object in 2D space (for example creatures can't enter it)? I know mesh colliders are 3D creatures so can't collide with my 2d sprites but i can't find a way to have the line of sight rigid.
@cheezcola
@cheezcola 4 года назад
I wish you had a class on everything from 18:30 onward. I like to be able to implement everything and have a deep dive on it. Any suggestions?
@jacobwolnowski1578
@jacobwolnowski1578 4 года назад
he's just kind of like: "step one: draw a triangle step two: color the triangle in step three: go over to the custom forward rendering script that you just know how to get and somehow knew ahead of time I was going to tell you to use."
@sirpentineplays5560
@sirpentineplays5560 2 года назад
@@jacobwolnowski1578 do you know how to implement it? i can't find it anywhere
@ComprarAlimento
@ComprarAlimento 2 года назад
mini tutorial for those who didn't get it: 1 - install universal RP from package manager. 2 - Create a "pipeline asset". 3 - Assign the custom pipeline in player settings (graphics tab). 3 - Create the layers as seen in the video. 4 - Change "UniversalRenderPipelineAsset_Renderer" (or whatever you called) adding the "Render Objects" (Mask, behind mask and black) and changing the values according to the video. 5 - Remove those layers as seen in video but only on "Transparent layer mask" (keep them selected on "opaque layer mask"). the rest is easy...
@daxetor4991
@daxetor4991 2 года назад
@@ComprarAlimento the 5th one helped me a lot. thank you so much!
@user-or1ok1sp5j
@user-or1ok1sp5j 2 года назад
@@ComprarAlimento Hello I from Russia and I ask you to explain the tutorial in a little more detail
@cadebender7101
@cadebender7101 3 года назад
So should I use Universal Render Pipeline for this or HDRP?
@henyersbaltar219
@henyersbaltar219 4 года назад
I'm using this tutorial in a combination with what I am already making. Okay so for some reason the origin of my cone is at an offset to the right of my player and anything that collides with the FOV is also projected at an offset to the right. I tried to look all over the code to see if I did anything different from what you did but i noticed no mistakes. Do you have any suggestions on where I should look to see why this offset is occurring?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 года назад
Check the position of the FieldOfView Game Object, it's probably not at 0,0 You can download the project files and directly compare with your own
@colinmasucci4044
@colinmasucci4044 3 года назад
I had this same problem. I believe it had something to do with it being a child. Once I made it its own object it was fixed.
@postymusic4387
@postymusic4387 2 года назад
@@colinmasucci4044 I have the same offset problem. it only occours when the FOV is a child of the player. I would like to make all this a prefab, so also enemies can use it, is there any fix to it?
@bogumiwyrwa216
@bogumiwyrwa216 4 месяца назад
Hello, I have tried make Field of View for 3D and it works when player do not move. I have problem with SetOrigin and SetAimDirection. Do you have some advices for me?
@loisdeniau1225
@loisdeniau1225 3 года назад
I do manage to make it work with URP in 2020: -create a new 2d project (without URP) -import the package -install URP -in project settings -> graphic, put the render given in the project -put the mask material alpha higher than 0.5 For some reasons create a project already with urp before import the package does not work (Maybe some LWRP / URP conversion not doing well, have no clue) Also, you need to add a new sprite for the floor (because he is missing)(put the white pixel for instance, don't forget to expand it). You can lower the treshold of the mask shader to 0 to hide it (I don't really understand why but a value lower than the treshold make the mask material unusable).
@notanagger4861
@notanagger4861 Год назад
my sphere and fov object overlap creating a darker triangle at the space they overlap at, how do I fix this?
@frithjofmeinke7789
@frithjofmeinke7789 3 года назад
Great tutorial! The last part about the CustomForwardRenderer really could have saved me hours of research about custom shader programming in the URP without the Shader Graph. Does someone have any tipps on how to make the edges of the Mask softer/blurred out like in the game Survirvor Squad? Thanks in advance and keep up the great work!
@sirpentineplays5560
@sirpentineplays5560 2 года назад
sorry to bother you, do you know how to get the customforwardrenderer in your project? i've looked everywhere and can't find it anywhere
@frithjofmeinke7789
@frithjofmeinke7789 2 года назад
@@sirpentineplays5560 Sorry i can't help you.. I am currently working with UE and didn't touch Unity in a while.
@DahamVoid
@DahamVoid 3 года назад
great tutorial as always. I cant figure out how to create a half-transparent material, anyone can help?
@leonardomorselli5265
@leonardomorselli5265 4 года назад
I have a problem, i dont have a player to move the field of view since i wanted to use it like a "light source". It doesnt need to illuminate my scene, just to visualize a cone of light. Anyway, if in the scene window (while playing) i try to move it, it didnt update the collisions. So i created an object called light source and attached its transform position to the SetOrigin, which I call every update of the mesh script (the one u showed in the video). It doesnt work, specifically the mesh moves faster than the object, making it like every collision has an offset if i move it. Help pls. If instead I just move the walls it works fine.
@jerematic10
@jerematic10 3 года назад
I'm having this same problem, did you ever find a solution?
@leonardomorselli5265
@leonardomorselli5265 3 года назад
@@jerematic10 no sorry man
@TheAnonymousLemur
@TheAnonymousLemur Год назад
I'm having trouble assigning a color to the Rays. It appears to only allow materials, and when I make one, even if it's transparent, it doesn't assign, there is only one built in swatch (material/color/whatever) that even get's anything to show up.
@ruchanadguzel1237
@ruchanadguzel1237 4 года назад
What should i learn thing(for ex. Physic, vector) for understand this subject
@matthewventures
@matthewventures 2 года назад
How did he add the fuzzy effect around the edges? Not in this tutorial but I see it in the completed game.
@creativegeniusgames7543
@creativegeniusgames7543 4 месяца назад
Do you have a video regarding how you set up the Black Layer and the CustomForwardRenderData? It's the light and shadow affect I'm most interested in, and how you hide objects using the dark layer, but it seems like I'd need to learn a great deal about Render Pipelines just to implement that one feature? I also have weird interactions where the mesh I have draw is either behind or on top of everything in my scene (usually behind), it doesn't seem to follow the same layer rules that sprites and Canvas based objects use? I've tried other variations, but the ability to "cut a hole" in one layer/image using the mesh you've demonstrated doesn't work with this code as it would with UI elements or DrawLine
@dolguldur1833
@dolguldur1833 2 года назад
Hi Codemonkey, As far as I know, using the forward renderer doesn't allow us to use 2D lighting, only the 2D Renderer does. Is there a way to implement this while being still able to use 2D lights?
@dknyoiwi
@dknyoiwi Год назад
You can use an asset called smart lighting2d as a light source
@zbeb118
@zbeb118 2 месяца назад
Hey codemonkey, thanks for the amazing tutorial as usual, quick question, I am making a hide n seek game and the seeker has the effect you just made, but what if I wanted to be the hider? The render settings also apply to me, how would I be able to disable them if I were to pick hider and be able to see everything as normal but still have the seeker only see what is in it's fov? (It's a multiplayer game that's why I am worried about the seeker too)
@alfonso.k
@alfonso.k 14 дней назад
I have the mesh and the mask all working fine individually but can't get the mask layers interacting each other. I suspect that it is a issue with a shader but haven't been able to figure out.
@fredchicken4922
@fredchicken4922 3 года назад
thanks
@sanchithkrishnan
@sanchithkrishnan 4 года назад
Help Me! the Field of View does not render if I am not moving and the origin of the field of view is at the player's position only at the origin whenever I try to move it, the field of view shift from the player's position.
@dethdethdethable
@dethdethdethable 3 года назад
Thanks for all your videos. I am having an issue with this one. I'm on Unity 2020.1.1f1. I seem to have an issue after moving everything into the start and update functions. I did a Debug.DrawLine just to see what might have caused the issues. One issue was the tilemap having a large invisible overlay that made the mesh show weird shapes if I moved the tilemap (All on the same Z position) the other seems to be that no matter where I move the Mesh, one ray seems to always go to position 0,0,0 no matter what. Even when I drop the rayCount to 1
@maximielos
@maximielos 2 года назад
I struggled a lot to get the enemies to appear within the FOV. They were either not appearing at all, not disappearing, or only visible outside of the FOV, but changing the Queue for the mask to Opaque worked for me. Hopefully, this will help other people that are struggling with this.
@lukaivicevic
@lukaivicevic Год назад
This worked for me, thank you!
@lspremul
@lspremul 4 года назад
Hi Code Monkey, I was curious if you have looked into this rendering technique with the 2019.3 URP? I am trying to use that to make it work, but it just seems like none of the Render Features (Mask, Behind Mask, Black) in the pipeline asset are even taking place despite following the setup you showed in the video. Any help would be greatly appreciated!
@lspremul
@lspremul 4 года назад
I seem to have gotten it to work now, I needed to change the FieldOfView Shader type to "Universal Render Pipeline/Simple Lit" and now it's working perfectly
@tobiacancelliere6972
@tobiacancelliere6972 4 года назад
Didn't work for me after the mesh rendering. I don't understand how the FOV material has an alpha setting (mine doesn't), I don't know why the object in the behindMask layer don't disappear, the FOV ray fin is purple.... Does anybody have suggestions? I followed the steps religiously, as close as possible using the URP (as the LWRP has been discontinued apparently) but nothing I do seem to change anything
@davidson2727what
@davidson2727what 3 года назад
I'm trying to convert this into 3d. I have some debug rays being drawn and they are all near the player and move with the player when the game starts, but the rendered mesh moves much faster in the X, Y, and Z directions. Do you know what could be causing this?
@davidson2727what
@davidson2727what 3 года назад
Talked with a guy on unity forums. Basically the mesh is using world space while the debug rays are using local space.
@tonyj2800
@tonyj2800 2 года назад
This was very helpful!, I too was running into that issue that it has been a pain to figure out. Thank you so MUCH!!
@tonyj2800
@tonyj2800 2 года назад
@@davidson2727what Any chance you can share how you fixed the issue? since I am assuming that Physics.DrawRay would also be localspace
@radian825
@radian825 4 года назад
How did you make this Mask material? If I add a standard material. It is black (although the color is set to green), and not transparent (alpha is set low). When Importing the files of the project the material shows the following error "Hidden/InternalErrorShader".
@smoq20
@smoq20 4 года назад
Same problem here
@jishnubhattacharjee5112
@jishnubhattacharjee5112 Год назад
Hey there, I know this is a old video but what is the layer for the player? And the Default Layer is not there in URP
@baohuynh9542
@baohuynh9542 Год назад
i'm stuck in the collision part. the fov doesnt stop at the object but it is skewed forward, near the start of fov more than the object. Can anyone show me the problem, please?
@michallisy3488
@michallisy3488 3 года назад
Hi I just wanna ask when you set vertices as new Vector[rayCount+1+1] is it different from rayCount+2? Or it is the same and you just write that way for better understanding?
@CodeMonkeyUnity
@CodeMonkeyUnity 3 года назад
Same thing, it's just for easier understanding the logic
@sombr4ayaya556
@sombr4ayaya556 4 года назад
Cool '-'
@dawidczaja6967
@dawidczaja6967 4 года назад
Hi, got strange problem with this.... I've switch it to 3D and rays update them self's only when obstacle is moving, but that is NOT the biggest issue... Main problem is with mesh and rays updating to not position of colider but to colider offset by some value, despite it being set to zero in all directions. Any suggestions?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 года назад
Check the scale of the game object. Did you make it a child of something else? Add some Debug.Log's and try out with a single ray.
@SwitchZetto
@SwitchZetto 3 года назад
How do I make the LWRP part work with URP? Some things are very different like Opaque Layer Mask and Transparent Layer Mask
@kayyyng1858
@kayyyng1858 2 года назад
Same question
@poltergeist6917
@poltergeist6917 3 месяца назад
Is there a way to make the behind mask layer still visible in the editor? It makes stuff a bit more convenient in the editor
@aigen-journey
@aigen-journey 4 года назад
This might be a stupid question, but why not use lights? for the visual effect (you would also get a nice smooth transition), or a static plane with the light 'cone' taken from a texture?
@CodeMonkeyUnity
@CodeMonkeyUnity 4 года назад
That depends on what game you're trying to make, for some games a smooth light might be nice, for other games being able to clearly tell how far you can see might be better. So the question kind of becomes, do you want a lighting effect or a game mechanic? For example in the next video I will apply this effect to the enemies in order to make a very clear enemy view cone, like in Commandos or Desperados, that is perfect for a Stealth game. You can clearly see where you are safe and where you are not.
@4randylarson
@4randylarson 3 года назад
@@CodeMonkeyUnity As a general comment, I think this is perfect to combine with lights. If you want a FOV environment then lights that are obscured from the FOV (e.g., behind a wall) should not be visible. Lights, once they are in the FOV would be great to illuminate the area. Following this, your FOV angle could be 360 and this would generate a mesh that was then lit as your lights dictated. I went to Google with a notion of how to generate exactly this. I figured it was mesh related, but the exact mechanics I was unsure of. Thanks for this video and others on you channel. Your insight and presentation are outstanding and super helpful.
@Tiparium_NMF
@Tiparium_NMF 3 года назад
I fee like you went through the section where you make the field of view actually show enemies a little too fast. Other than that, great tutorial.
@sathwikdevunoori7178
@sathwikdevunoori7178 Год назад
Hey can anyone help me... I'm facing issue with colliding the ray for cutting the mesh I'm currently working on 3d project is that the issue causing idk but if that's the issue can anyone tell me the solution..
@ollewahlstrom1936
@ollewahlstrom1936 4 года назад
Great tutorial! I'm pulling my hair trying to figure out an issue though. Everything works as long as I have alpha on the material on the field of view gameobject to >0.5 which then shows it very clearly green. any lower than that and the green disappears but then the black layer is rendered instead and no object that are supposed to be show in the mask (fov) are shown and it's just dark... I'm so confused. It doesn't help that there seem to have been a version bump since you did this and the version I have so the custom rendering pipeline has some different settings, not much though.
@fartedididnot3685
@fartedididnot3685 6 месяцев назад
I have the exact same issue. Did you ever find the fix?
@jabbathetrump187
@jabbathetrump187 6 месяцев назад
​@@fartedididnot3685Did you find a fix?
@fartedididnot3685
@fartedididnot3685 6 месяцев назад
@@jabbathetrump187 I actually did! I can't remember exactly but its something like this: If you go inside the actual material editor, not sure what its actually called but its a similar look to unreal blueprints. There you should be able to change the color to white, and there should also be a 0.5 option there too. Change that to something much lower and the mesh should appear below 0.5 opacity.
@inf3243
@inf3243 19 дней назад
@@fartedididnot3685 thankyou!
@lehcaR_0731
@lehcaR_0731 Год назад
I noticed that in the Survivor Squad game there is a special effect of zero color saturation in the scene outside the field of view, which is not found in the FoV tutorial. Can you do a related tutorial?
@dasmaffin1633
@dasmaffin1633 4 года назад
Unity just crashed the 2nd time on me why could that be? It crashes already at the part where I make the mesh
@FoleyX90
@FoleyX90 3 года назад
How do you do the black & white effect outside the field of view cone?
@cockconsumer658
@cockconsumer658 4 года назад
12:25(move thing to the update method) I Make every exact change but then my game crushes.Plz help!!
@fartedididnot3685
@fartedididnot3685 6 месяцев назад
Hey Code monkey! Mostly everything is working perfectly for me, however I have only one issue. The mask material given from the project is only visible up to 0.5 alpha with green light. Anything lower than that, and it disappears completely, including the behind mask layers. I'm not sure if I may have missed something, or if its an update of unity itself. Any idea?
@CodeMonkeyUnity
@CodeMonkeyUnity 6 месяцев назад
That's odd, does it suddenly go from faded green to completely invisible? Try hiding the background, is it still invisible? Maybe there's some sorting issue and when it's under that alpha it renders below the background. Try changing the sorting order or the position slightly
@iLagSoUhax
@iLagSoUhax 4 года назад
Hey! I had a question; i am working on a 2d multiplayer stealth game, and ive made a playable character who can deploy a smoke bomb, which is supposed to block the line of sight of enemies. But, if i make it solid, players cant pass through it, and if not it does not block players' field of view. Any tips? also, how can i make it so that is a player is using a pre-placed camera-tracker, it would enable a viewcone where that tracker is pointing? Thanks!
@CodeMonkeyUnity
@CodeMonkeyUnity 4 года назад
You need to play around with Layers. On the project settings you can define which Layers interact with which, so you can make a layer collide with the Line of Sight but not the player.
@michaelong348
@michaelong348 4 года назад
how do we do in in the universal render pipeline? it doesn't seem to work in mine
@doomfox4783
@doomfox4783 Год назад
I need help my field of view raycast are hitting objects from the player but the mesh is way faster than the player
@dekabreakable
@dekabreakable Год назад
For anyone having issues with the FOV origin being offset by a some units, make sure that for the tutorial, you set the FOV gameobject to 0, 0, 0. That was not mentioned in the tutorial in any meaningful way.
@adventureman6997
@adventureman6997 6 месяцев назад
use URP not 2d core o wait its been a year 🥶
@gaerex1334
@gaerex1334 4 года назад
Dude, you are just fucking amazing, thank you a lotttttttttt, you kept me helping out from when I started my journey, you are doing amazing work, may God bless you. ❤❤
@WakeTheShark446
@WakeTheShark446 3 года назад
Could you please update this tutorial so it better covers the stuff around the 18 minute mark and show alternatives to the Render Pipeline as from what I can see in the comments, that's no longer supported.
@tuvokjohannsen123
@tuvokjohannsen123 4 года назад
How does this work with the new URP in UNity 2019.3? Messed something up. It worked finde in the previous version, but now I've problems
@CodeMonkeyUnity
@CodeMonkeyUnity 4 года назад
I haven't tested it with 2019.3 but the URP is pretty much the same as the LWRP so it should work just fine What problems do you have?
@TheKacperuss
@TheKacperuss 4 года назад
@@CodeMonkeyUnity Not the same guy and 3 months late but I was also working on 2019.3 with URP. In my experience, for some reason the stencil override option just ticks itself off when running the game, effectively removing all changes. I couldn't find any solutions or even anyone mentioning the problem. Both depth and camera options work just fine, but stencil resets each time you try to run the game. I tried it on 2019.2 and I can confirm it works fine, it's not me being stupid. It really seems that something in URP in 2019.3 causes stencil to be... Ignored? Skipped? Reset? Turned off? I'm sorry if you already discussed this problem. I couldn't find any of your latest videos being about render pipelines, but maybe I missed something.
@FluidicClient
@FluidicClient 4 года назад
@@TheKacperuss I'm having the same issue, apparently there's a bug in the current version of unity. Guess it's a case of waiting for the next build or reverting to an old one.
@yagamilight2274
@yagamilight2274 4 года назад
Thanks dude I am first 💟
@Username5278234
@Username5278234 Год назад
Howdy there! Kind of a niche question, and I know this is an old video, but I figured I don't know where else to go. My FOV works beautifully, up until my player collides with a moving object ie the bullets my enemies are shooting. Then the vector from angle and angle from vector float suddenly start changing rapidly within a small margin, which results in a flickering of the fov's borders, seems to be rapidly changing position. I found I can resolve this by pressing my character against a wall until the values normalize, but my player character is not moving, nor the origin, nor the aim direction while this is occurring. Super specific, but any insight would be wonderful, thanks!
@CodeMonkeyUnity
@CodeMonkeyUnity Год назад
Since you say it happens on a collision maybe your player has a rigidbody and is being pushed back when hit by something? There's nothing in this specific code that should cause any jitter like that. Add some Debug.Log to see what the code is doing but it doesn't sound like the issue is related to this FOV code
@michiblk4581
@michiblk4581 4 года назад
Is it possible to let already passed sections stay revealed? I currently make a map where areas which are already were seen is visible.
@CodeMonkeyUnity
@CodeMonkeyUnity 4 года назад
For that you need something different that can store what areas have already been uncovered. The simplest way is just a basic grid with a bool for visible or not and visualize by showing or hiding a black visual for each grid position.
@lepaz9826
@lepaz9826 4 года назад
Can you use this tutorial in a 3d topdown shooter?
@gongal
@gongal 3 года назад
Is there any trick on doing this with FOV object being a child object of the character object?
@bluesyntax5355
@bluesyntax5355 4 года назад
Hey, so i am using this. in 3d and the mesh goes. down trough the ground 90 degrees... what should i do / rotate?
@davidwarneke3469
@davidwarneke3469 3 года назад
When you set up your GetVectorFromAngle() method, where you tell it what to return, put a 0 between the mathf.cos, and mathf.sin, so that it works on the x,y, and z axies.
@davidson2727what
@davidson2727what 3 года назад
I know this is a late reply but making in this in 3d required me to write my own GetVectorFromAngle function. In that function this is my return statement "return new Vector3(Mathf.Cos(angleRad), 0, Mathf.Sin(angleRad));" The mesh is on what is the 'ground plane in 3D' but its facing the wrong way, this should be fixed later once it is attached to the player. Hope this helps you or someone else.
@khiemnd777
@khiemnd777 2 года назад
This is awesome, does it work well with Unity WebGL?
@chelsais
@chelsais 3 года назад
!HELP! For some weird reason when I do 11:56 my FOV turns into a small rectangle. How do I fix this?
@AmIDuckQuack
@AmIDuckQuack 3 года назад
same thing
@spoofersgaming
@spoofersgaming Год назад
So I am trying to use this code for an enemy to detect a player, but I can't figure out a way where it detects the player and starts the enemies follow script without it stopping if it sees a wall. Currently I have these lines of code within for (int i = 0; i < rayCount; i++) if (raycastHit2D.collider.CompareTag("Player")) { enemyScript.canSee = true; } else { enemyScript.canSee = false; } and if you couldn't tell this makes it so if it sees a wall and the player it stops. Is there a better way for me to do this, so the enemy won't stop if it sees both a wall and the player?
@pcccmn
@pcccmn 3 года назад
Dude, what on Earth is your FOV's Shader's settings?
Далее
I Made the Same Game in 8 Engines
12:34
Просмотров 4 млн
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
Советы на всё лето 4 @postworkllc
00:23
How do non-euclidean games work? | Bitwise
14:19
Просмотров 2,4 млн
Generating A Hex Map With Fog Of War in Unity
20:27
Просмотров 50 тыс.
6 Years of Learning Game Development
9:02
Просмотров 2,4 млн
Recreating Darkwood's Vision Effect in Unity
4:01
Просмотров 48 тыс.
Making a Game in ONE Day   (12 Hours)
10:26
Просмотров 3,3 млн
3 Hours vs. 3 Years of Blender
17:44
Просмотров 4,4 млн
Why Making Multiplayer Games SUCKS
6:46
Просмотров 415 тыс.
I Made a 1D Game 🎮
11:18
Просмотров 1,7 млн
How I Made a 3D Platformer in 2D Game Engine
21:23
Просмотров 458 тыс.
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21