- Home /
How to fade gameobjects scrolling toward the camera
I'm working on a small project for class and I'm trying to create a smooth fading effect. The setup I have is a single camera with a gradient texture as the child so I have a constant static background. I also have a few blocks positioned in a scrolling fashion coming towards the camera. Currently, I have it set up so that the camera is my player, and I am moving it towards the line of blocks. Because the gradient is a child of the camera, it moves relatively with the cam, and after the blocks pass the gradient, they kind of just pop into view. Here are a couple pictures of the setup:
I was wondering if they was any way, perhaps using C#, that I could fade the blocks towards the camera after they reach a certain distance, or like have a transparent fog of war as a child of the camera fading them into view. Or maybe even have a trigger event with the gradient that would fade the blocks in after passing the texture. I feel like some of this should work, I just have no idea how to implement a fading feature without using alpha and a canvas group to fade the entirety of the objects. It looks too clunky just popping into existence like it is.
I was also wondering if it's possible to do this without needing to add a script to each object; a script that would fog the camera's distance would be best for this setup if it's at all possible!
Thank you in advance,
Joshua