THANK YOU MAN, YOU SAVED MY PROJECT. I spent all along last day trying to figure out something, trying to compute shaders to do this, THANK YOU VERY MUCH
@LlamAcademy Жыл бұрын
You’re very welcome! I’m glad it could save your project!
@poobagification2 жыл бұрын
Great video as always. Congrats to you and Andrew Bowen on that phenomenal support!
@renman3000 Жыл бұрын
Wow! Thanks. Crazy that such a simple task would be so complex!
@LlamAcademy Жыл бұрын
Yeah it was a little tricky to figure out 😅
@stylie473joker5 Жыл бұрын
@@LlamAcademy Thanks for the hard work, just wanted to ask if this also works with details that are painted with unity's detail paint brush like trees and such
@LlamAcademy Жыл бұрын
I don’t think this will work out of the box with Unity Terrain with trees, grass, and other details placed.
@NatadTech7 ай бұрын
Thank you so much bro for hosting it at github and not like some other who host it on their patreon
@ray691108 Жыл бұрын
Omg, you are awesome! super thanks for your example! you deserve more followers and attention indeed!
@LlamAcademy Жыл бұрын
Thank you 🙏 I appreciate that
@chrisb60792 ай бұрын
Thanks for doing this tutorial
@LlamAcademy2 ай бұрын
Glad it could help you!
@Romored7 ай бұрын
I rarely comment on videos but this time I will ! Really nice video and awesome tutorial 🔥 Have a nice day ! ✌
@infernumex2 жыл бұрын
I can't pretend I completely understand this script, but I was able to tweak it for my game, so thank you!
@LlamAcademy2 жыл бұрын
Great! 🙌 I don't fully understand what all of the things we're toggling do either so 🤷♂️sometimes just have to just accept some magic :)
@dreamisover98132 жыл бұрын
This channel covers interesting topics, thx
@eyadmohamed-vt7gl7 ай бұрын
You are the Smartest man on the earth you solved the problem that i could not solve for 5 month Thank you very much
@LlamAcademy6 ай бұрын
😅 I don’t know about that, but thank you! I’m glad it helped you!
@LuqmanHidayat002 жыл бұрын
awesome, great tutorial! i can see myself using this in the future. i'm gonna save it to my playlist
@LlamAcademy2 жыл бұрын
🙌
@dimitardimitrov79504 ай бұрын
LoL, thanks for the tutorial, I followed it to the tee, it worked for me, no errors, but at one point the material wouldn't fade back in, I'm not a programmer, so I shamelessly copied your script from , git, thanks man, amazing tutorial :D
@dimitardimitrov79504 ай бұрын
did change it to SphereCastNonAlloc with a radius of 1 for my game
@LlamAcademy3 ай бұрын
That's why it's available :) Glad it helps you
@oldbelt2578 Жыл бұрын
Thank you! this works perfectly!
@Equisdeification2 жыл бұрын
Hey! I love your channel, you are always giving excellent info
@LlamAcademy2 жыл бұрын
Awesome to hear! 🙏 I appreciate that
@rickzhang91582 жыл бұрын
Great work and I've learned a lot from your video! Unfortuantely when I tried using your code in my project, it appeared to have a bug when encountered with more than one object in the way. When there are 2 objects between player and camera, the fading process worked fine, but when the player walked out of the objects, only the object near the camera returned to opaque, and the other one (blocked by the object near the camera) stayed transparent. That's how I conclude the problem here. Bad at code, I can't fix the issue by myself. Guess this methond only works well in open area. But still, this method is fantastic!
@LlamAcademy2 жыл бұрын
Hmm……. I will check that out maybe I pushed some incorrect code after doing the editing on the video. Let me get back to you. The idea is this supports as many objects blocking view as you allow RaycastHit array size to be.
@hamzakontaz6066 Жыл бұрын
Thank you so much for this effort
@rqbh6 ай бұрын
Raycast can not detect object
@alexleonardkrea2 жыл бұрын
Very clever sir!
@LlamAcademy2 жыл бұрын
Glad you think so! Thanks!
@DioTravel4 ай бұрын
This isn't working for me yet. I feel like I'm really close though. Nothing is showing up in the Objects Blocking View array. I have two objects with colliders and the Fading Object script. I thought it might be the Target Position Offset because I'm not seeing anything change when I change the X,Y,Z values. Either that or the Raycast is not hitting the objects. What would you recommend I do to debug this?
@LlamAcademy4 ай бұрын
To debug this I like to make an editor script that draws the raycast for me with Handles.DrawLine() based on the direction and start position of the camera. Somehow a lot of times I mess up the raycast and it's not hitting what I expect. If you see the line going through all the objects, double check the layer mask you're raycasting on and the layers of the objects you expect to be hitting to see if there's something wonky going on there.
@DioTravel4 ай бұрын
@@LlamAcademy Thanks so much, I got to work! Looks like it was the layers of the objects and the layermask that was making everything wonky!
@antlermind Жыл бұрын
Awesome tutorial here, what an amazing wealth of knowledge your channel has! That being said.. I am having some difficulties getting this working. Currently, there is one spot on my mesh that does turn transparent when blocking the player, but the rest of the mesh stays opaque. Is there any special magic that needs to be done within the URP shader to make this work correctly?
@LlamAcademy Жыл бұрын
Hi! Sorry for the delay in response, it's been a crazy few weeks for me lately. For your issue... I'm not sure how you could have that happen. Because the FadingObject script finds all child renderers and we iterate over all materials, I can't imagine a scenario where you could run into that if FadingObject just pulls all children. There's no magic material properties on the Standard Lit Shader in URP that would prevent it from fading out. Some ways I could imagine that would result in what you described would be: 1. If there are overlapping objects, some without colliders, that are not parented under the object that has a collider + FadingObject. The secondary object would not be considered and not fade out 2. If FadingObject has Renderers assigned in the inspector that are not the full set of Renderers to consider. If you can send a video of your scene setup and the issue maybe I could spot something funny? Or if you have a small reproducible repository I could check it out as well
@rqbh6 ай бұрын
Not work anymore in Unity2022.3 , is there any other steps to do except add two scripts ?
@LlamAcademy6 ай бұрын
The objects that can obstruct the camera need a reasonable collider or it won’t work! Do you have colliders on your objects?
@rqbh6 ай бұрын
@@LlamAcademy Yes, i use the same sense , the starter 3th person
@lawrence97134 ай бұрын
Do you need a fix player for it? Could it be done in a game like Age of Empires/ City Skylines, just fading out objects because the cam is zoomed in or something
@LlamAcademy4 ай бұрын
Works with any target
@steve-banbury-creative-xr Жыл бұрын
Thanks for putting this together - just what I need for a project I'm working on and I will be following it in detail. BUT... can I just ask... is it absolutely necessary to put music in the background, particularly on a repetitive loop? I find it hinders following the tutorial, which is kinda counter productive. I've had to remove my headphones and take a break so many times purely due to the background music. It will eventually drive me to distraction! Can we just have the education without the background elevator music, please? Otherwise, keep up the fantastic work!!
@LlamAcademy Жыл бұрын
Thanks for the feedback! When I go back in time and review my older videos I see a lot of room for improvement. One of those (many areas 😅) is the too loud background music that obviously loops. I hope in more recent videos you find the music choice and volume less distracting.
@steve-banbury-creative-xr Жыл бұрын
@@LlamAcademy Thanks for the response! Unfortunately, once you've focussed on the music it's really hard to just ignore it - I have tried :). The content of the tutorial was very helpful though. I only really wanted the bit about fading a 3D object with URP, but I found much more than that, which I am sure will be very useful in the future.
@falricthesleeping9717 Жыл бұрын
Hey nice video, at the first of the video you said you can use shaders, well where can I find any source for how to do it? thanks
@brianparkhurst5352Ай бұрын
This works great, until I add a ridgedbody component to my object. I need objects to fade, but also need collision detection. I cant seem to figure out what I'm overlooking here. UPDATE:: My children object had the Fade Object component added to them which worked great, Until I added a ridged body component to the Empty parent object for box collision. To fix the issue I added the Fade Object to the parent object, and it worked again. Problem Solved!
@LlamAcademyАй бұрын
Thank you for sharing your update 🧡! I'm sure someone else will run into the same issue and appreciate that
@brianparkhurst5352Ай бұрын
@@LlamAcademy So I did a build and run test on my project and the fade function doesn't work. Works great in the editor but fails to implement in the build. Any thoughts where to begin debugging this issue?
@LlamAcademyАй бұрын
Sometimes in the build Unity will strip shader variants that are not used. That’s configured in your project settings / graphic settings. If you aren’t using any transparent materials sometimes this variant doesn’t get included in the build. You can add that variant as a preloaded shader to ensure it’s always included.
@calvinms7503 Жыл бұрын
thank you!
@LlamAcademy Жыл бұрын
You’re very welcome! ☺️
@jameslafritz2867 Жыл бұрын
Hey, Great Video. Is there a reason you chose to go this route instead of using the "Render Feature" of the Rendering->URP Render Pipeline, you may have a video on this already. I use 2 "Render Objects" One for when the character is behind an object and one for when the character is in front using the depth test. if a character is behind an object it use a dither material that I have set up to make it appear as the object is sim-transparent. But there is always the ability to create your own custom render feature that could fade the object out instead.
@LlamAcademy Жыл бұрын
Honestly, I haven't looked into Render Features. When I implemented this effect, URP and Render Features were not out yet. This video was a direct URP translation from what I implemented in the Built-In Render Pipeline.
@jmprsh1532 жыл бұрын
Hey so im guessing i have to import the universal render pipeline for this to work? I was wondering what i would need to do to just use the normal 'standard' shader thats with the normal one. Also if i have to use the universal render pipeline do i have to do anything specific with the project as i try the shader but it makes all the textures pink
@LlamAcademy2 жыл бұрын
Hi! Yes this is specifically for URP. In the description of the video I have a link to the video showing how to do it with the Built-in render pipeline. The process is the same, but I give you the specific properties and values over there.
@watercat12482 жыл бұрын
Wen I have create therd person player controller in past I have use one system that makes the camera to get closer wean the hit in collisions The problem with that system is the fact block even if the are something small like columns fences ECT but I think if someone make acception for the spefic object I will perfectly fine
@maxg5196 Жыл бұрын
I'm currently implementing this into my game. I got it working like a charm like in the video. However, I want it to check an list of targets, not just one player target. Currently I am doing the foreach loop for each target in the list in the CheckForObjects coroutine. However, it is still only working for one target at a time. Maybe you would have a better understanding of why that is and how to implement this? Thanks
@LlamAcademy Жыл бұрын
If you have a static list of items that need to be checked, I think the simplest solution is to attach multiple of the same script with different targets. If it's dynamic, then I would expect you're doing it conceptually correct on the CheckForObjects. Could you send me a gist or something with the code? Maybe it's just a small tweak that needs to be made to what you already did.
@maxg5196 Жыл бұрын
@@LlamAcademy yeah it'll be a dynamic list: I have a script on the targets that adds them to the list when they enter camera view and removes them when they exit camera. What would be the best way for me to share my code with you? Discord?
@maxg5196 Жыл бұрын
Actually I believe I solved it myself. For other people's reference: essentially when doing the raycast check for each consecutive target, it overrides the array of the previous. And since the function which fades back in objects that are no longer being hit uses this Hits array, it only takes into consideration the last target checked. You need to save all the objects hit in a new array/list and use that in the FadeObjectsNoLongerBeingHit function
@LlamAcademy Жыл бұрын
Oh! Great to hear. I like to use GitHub Gists to share individual scripts: gist.github.com/starred
@danielhasi6974 Жыл бұрын
nice work, but its not possible if i using terrain and try to hide trees right?
@LlamAcademy Жыл бұрын
That’s right. The terrain uses a different shader and does not use the standard rendering with a MeshRenderer
@jjanor7745 Жыл бұрын
is there any way to fix the SSAO popping in and out? looks pretty terrible
@LlamAcademy Жыл бұрын
Hmm...I am not 100% sure you can achieve that very easily. Transparent objects usually are not included in the SSAO pass. Maybe you can tweak the settings of SSAO to go after opaque and change the render queue to something like Opaque + 1 to see if that works? Otherwise it might require custom implementation of SSAO to consider these objects.
@jjanor7745 Жыл бұрын
@@LlamAcademy Thank you for the answer! I'll see what I can do!
@phantomosteam3727 Жыл бұрын
Hello i have a different stile of my game that consist of cubes. I think this method is good for big objects instead but actually in my case only 2 cubes disappear and the rest remain opaque so i still can't see my player behind that cubes. Is there a method to give raycast more radius to area??
@LlamAcademy Жыл бұрын
Yes! A Raycast is an “infinitely thin” line. You can use a boxcast or spherecast if you need a wider area. You can check out this video to see how all types of “casts” work: kzfaq.info/get/bejne/nLCpnJqdl9q7e6M.html
@phantomosteam3727 Жыл бұрын
@@LlamAcademy Thank you very much for answer! But in your case you are actually using RaycastNonAlloc and i don't know how to feet it exactly to your script because each Raycast have different settings allocation and i think using non alloc is better isn't that?
@LlamAcademy Жыл бұрын
Yes, the NonAlloc is the most performant option since it doesn’t generate garbage. You can feed the BoxCastNonAlloc very similarly to RaycastNonAlloc. The video linked above has examples of how to feed each “cast” along with links to the documentation pages!
@phantomosteam3727 Жыл бұрын
@@LlamAcademy Yes i already watched these video before
@LlamAcademy Жыл бұрын
I will review this in the morning and get back to you
@adamzadorski77642 жыл бұрын
Great!
@LlamAcademy2 жыл бұрын
😎
@qqqwwwwq9 ай бұрын
Hi, I used your tutorial but for HDRP with a shader graph. On the line: " private IEnumerator FadeObjectOut(FadingObject FadingObject) { foreach (Material material in FadingObject.Materials) { material.SetFloat("_Alpha", 0.6f); // Here I pass the value of the variable } yield return null; if (RunningCoroutines.ContainsKey(FadingObject)) { StopCoroutine(RunningCoroutines[FadingObject]); RunningCoroutines.Remove(FadingObject); } } " I used my float variable. But I can't achieve a smooth fade out, because... "alphaFloat = Mathf.Lerp(alphaFloat, 0.6f, Time.deltaTime*1.1f);" triggers only in one frame. Tell me how to modify your code. Thank you!
@qqqwwwwq9 ай бұрын
Thank you, I figured it out myself))
@chuozt2 ай бұрын
Could you explain your solutions for this? I got the same issues.
@qqqwwwwq2 ай бұрын
@@chuozt I'll answer you a little later!
@qqqwwwwq2 ай бұрын
@@chuozt it was so long ago that I don’t remember what was there, here is the entire coroutine: private IEnumerator FadeObjectOut(FadingObject FadingObject) { float time = 0; while (FadingObject.Materials[0].color.a > FadedAlpha) { foreach (Material material in FadingObject.Materials) { if (material.HasProperty("_Color")) { material.SetFloat("_FloatAlph", 1f); AlphaStep = FadingObject.InitialAlpha; // AlphaFloat = Mathf.Lerp(FadingObject.InitialAlpha, 0.4f, time * FadeSpeed); for (int i = 0; i < 3; i++) { AlphaStep = AlphaStep - 0.2f; material.color = new Color( material.color.r, material.color.g, material.color.b, AlphaStep ); yield return new WaitForSeconds(FadeSpeedOn); Debug.Log(AlphaStep); } } } time += Time.deltaTime; yield return null; } if (RunningCoroutines.ContainsKey(FadingObject)) { StopCoroutine(RunningCoroutines[FadingObject]); RunningCoroutines.Remove(FadingObject); } }
@chuozt2 ай бұрын
@@qqqwwwwq Your objects' surface types are set to Transparent initially right?
@cyco3oy2 жыл бұрын
+1
@LlamAcademy2 жыл бұрын
♥
@michaelvicente5365 Жыл бұрын
looks promising, sadly I get an error "Assets\urp-fading-standard-shaders-main\Assets\StarterAssets\TutorialInfo\Scripts\Editor\ReadmeEditor.cs(79,23): error CS0115: 'ReadmeEditor.OnInspectorGUI()': no suitable method found to override"
@LlamAcademy Жыл бұрын
Hmm..... you can safely delete that file. It was just carried over from the Third Person Starter Assets from Unity. Which version of Unity are you on?