How to create 2D Torch with Glowing and Reflecting Light Effect for Unity game. Easy 2D Tutorial.

Опубликовано: 30 Сентябрь 2024
на канале: Alexander Zotov
24,004
360

#UnityTutorial #SimpleUnityGame #unity2dlight #unity2dtorch
In this video we will create a pretty simple but quite interesting and impressive torch with 2D reflection light effect.

TO BLAST! - My New Fun Relaxing Puzzle Game Available On Google Play Store
https://play.google.com/store/apps/de...

Consider purchasing my ULTIMATE UDEMY COURSE with great discount
https://www.udemy.com/how-to-make-gam...

First we add a brick wall to the scene. Then select brick sprite and duplicate it. Rename duplicated sprite to Brick Wall Normal Map. Change its import settings. Set Texture Type to Normal Map. Check Create from Grayscale option. Hit apply. Create new material. Name it Brick Wall Material. Set its rendering mode to Cutout. And drag and drop Brick Wall Normal Map to Normal Map slot. Uncheck Specular Highlights option. Select Brick Wall game object and drag and drop Brick Wall Material to Material slot. Our wall became dark because there is no light source in our scene.
Add a torch. Set its Order in Layer option to 10 so it's rendered in front of everything in the scene. To move a torch we add a simple move script to it. In this C# script we have dirX, dirY and moveSpeed variables. Then in Update() method we read arrow keys pressing and move a torch by by setting its transform according to Input and moveSpeed. Add this script to torch. Next let's create point light game object. Reset it. Place it at the point where fire is supposed to be and change its Z axis value so this light will be in front of other game objects. To make our fire burn more realistic I'm going to change point light intensity randomly between some values to create an illusion on flickering flame. Here is a script for it. We get light component and set its intensity randomly between min and max values every frame. Add this script to point light gamr object. Make point light to be a child of a torch. Next right click on torch and create new empty game object that will be a fire. Right click on fire and create another empty game object which will contain fire animation. Make sure it's selected then go to animation window and create new animation. Select all of the flame sprites and drag and drop them to animation time line. Modify number of samples to slow animation down a bit.
Select Fire Animation object and change its Order in Layer option to be between brick wall and torch. And you can add a sprite to it to make this game object visible in scene view. Place Fire game object above the torch.
Let's add some smoke effect. Create Particle System. Make it a child of Fire game object. Renema it as Smoke Particles. Set Start life time to 2. Start size to 3. Set starting colors alpha channel to 20. Set Simulation Space to World. Change Shape of Cone. Set Angle to 0 and Radius to 0,7. Check Color over Liftime and set its alpha channel in the and to 0. Set Renderers Order in Layer option to 4. If Smoke is still behind the wall then change its Z axis value to 0 or completely reset its position. Position it a little above the fire. Smoke effect is ready. Let's add some glowing effect. Drag and drop Glow sprite to Fire game object. Set its Order in Layer option to 5. Place it in the center of the fire. Like in Poin Light case I'm going to alter glow intensity to create some flickering effect. Here is a script for it. This script changes object colors aplhe channel value randomly between 0,5 znd 1 every frame. Add this script to Glow game onbject. Everything is ready to be tested. Hit play and see how it looks like.

You can support me through
www.patreon.com/alexanderzotov
or here
https://www.paypal.me/AZotov
Thank you)

Flame sprites here https://www.vecteezy.com/vector-art/7...

Brick wall sprites here https://www.vecteezy.com/vector-art/6...

Torch here https://www.vecteezy.com/vector-art/8...

Scripts here https://drive.google.com/open?id=0B94...

What this video is about and what it can be used for also: unity 2d tutorial,
unity tutorial, 2d torch unity, 2d light effects unity, 2d reflecting light unity, smoke particle system unity, smoke particles unity, 2d glowing light unity, How to create 2D torch with glowing and reflecting light effect for Unity game, 2d light torch unity, flashlight unity, fire light unity, fire animation unity, light animation unity, unity light, unity torch, normal map unity, learn unity fast, unity tutorial, how to make games with unity, unity how to make game, unity how to make 2d game, not as good as brackeys but good as well.