Unity VFX Graph - Muzzle Flash Effect Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
and today's video is about a very simple effect that is commonly used across many shooting games especially when there are weapons involved and as you have guessed by now it's muzzle flashes and muzzle flashes can take many forms and shapes there's not only one way we can make them depends on the weapon on the bullets on the powder on the weather conditions and so on that's why i made so many variations which are all available on my patreon page links in the description but this is the one i'm going to show you how to create and it comes with a free smoke texture which is super cool you know what else is super cool building an rpg game without coding that's right today's sponsor is rpg builder a unity extension that is highly customizable without you worrying about coding just look at all of these features that comes out of the box plus it's super well documented with more than 60 video tutorials on how to use the rpg builder and if you have a question thomas the developer is super active on this discard channel and will certainly help you and for a very limited time it has 25 percent of discounts there's a link in description and on the comments as well make sure to check that out is looking very promising so yeah let's jump right into it and let's see how to create the basic uncommon muzzle flash in unity with vfx graph so the most common way is to use two meshes this code and these two planes and i use a blender to create them for the cone i start with a circle that i added with shift a then with tab i'm going to enter in edit mode select everything and press e to extrude and then i'm gonna press escape so every vertice is left in the same place and now with s i'm gonna scale this down until more or less around here i selected everything with a and i pressed u to choose light map pack and then with control tab i select faces and select one face and then select everything with a again and press u to choose follow active quads this way if we open up a window right here and if you go to the uvs this way you will notice that the uvs are straight just like this the only thing remaining to do is to fit them in the uv area and you can go to uv and turn on constraint to image so it doesn't go out of the boundaries of the uv area so the uvs are done which are really important just make sure the vertices outside are facing up in the uv area and that's it we only need now to add with ctrl r a little bit more of geometry and while holding shift and alt with right click we can select all of these vertices and with o you can turn on proportional editing and press g basically we want to end up with this cone right here and in object mode i'm going to press space bar to search for shades moods i'm just going to rename this to muzzle cone so i can easily find it in unity finally let's rotate this let's press r and then press x to rotate 90 degrees and for the other mesh with shift a let's add a plane press g and y and then 1 to move it to this position and let's change the pivot by pressing ctrl shift alt c and select origin to 3d cursor this way every time we scale this it will scale from this pivot now if we enter in the mode for the uvs we can rotate this 180 degrees so this edge faces down after that with a you can select everything and press shift d to duplicate this geometry and rotate it 90 degrees the y-axis so we end up with this object and we are creating this geometry because we want the muzzle flash to be seen from every angle now let's just rename this i'm going to rename it to mesoplanes and finally we can save it directly to unity well now inside unity make sure you have in the package manager install it visual effect graph and also go to preference and down here in visual fx turn on experimental operators blocks right so with that being done we can start with an empty game object rename it reposition and then in a folder let's create a visual effect graph once again rename it and then parent to the empty game object and press the edit button to open vfx graph rearrange a little bit to your workspace and press f to focus on your particle system in case you don't see it and we can delete the output particle quad because we want to output a mesh a particle mesh as you can see it's emitting capsules but we want to emit the planes we created right so in this icon let's search for muzzle and we have right here the muzzle planes if we switch the shading mode to wireframe you will notice that planes are being expounded and for the metal flash we don't need velocity let's remove this module and we don't want a constant spawn rate we want the bursts of one particle for now as you can see this is not facing the z-axis the blue axis personally i prefer it faces the z-axis so i'm going to use the set angle to rotate minus 90 degrees and not 90 degrees like i did this way when we control the set size down here you don't need to set it to -1 in the end it's the same thing but instead of using negative values you can use positive values in the set size now for the next part we need a muzzle texture and there's two options you can quickly google muzzle flash and you will get plenty of muzzles or you can open up photoshop or krito or something similar create a new file and in a new layer you can press pen to access the pen tool click more or less around here and while holding shift click again up here and with right click you can select stroke path make sure the tool is brushed and that simulate pressure is on and once you press ok if you don't see this you can press ctrl z and then you can press b and you can choose the size of your brush mine is around 500 pixels you can also go to the brush presets and see what's there and give a different feeling to your muzzle flash i'm going to leave the default brush and press right click make sure simulate pressure is on and you get this texture and then you can press right click and delete path now let's duplicate this layer rotate it with ctrl t and push it more or less around here make sure it doesn't touch the boundaries of the texture otherwise it will be clipped in unity then you can duplicate again the original layer and we ctrl t you can push it more or less around here and stretch it until you have something that looks more or less like this you can merge all the layers if you want with ctrl e by selecting the mouse and that's it you can save this photoshop file directly to unity back in unity in the main texture now you can choose your muzzle flash and as you can see we are starting to have something we created those two planes so it gives this 3d sensation to the muzzle obviously if you want now you can give a few touches to your texture so the next step is timing a muzzle flash is something super quick so in the lifetime we are going to make sure it's between 0.05 and 0.15 another thing this needs is to grow so let's use a set size over life and in composition let's set it to multiply down here in the curve we want this one so it starts small and grows bigger really fast but we are missing color so let's add a set color node and this time we can create a color property connect it down here and then we can choose an orange more or less like this and increase the intensity so you get this nice bright nozzle flash now for the set size forget that i have negative values we can set it to random because muzzle flash is not always the same size and we can also use the set scale and we can stretch for example in x it will stretch like this and z this is how it looks and in the y it's how long the muzzle is going to be so we are going to set this to random and for example you can insert these values basically sometimes it will be longer sometimes it will be shorter it will add a nice randomness to the muzzle flash another thing we can do to add more randomness is multiply the color with a random number between 0.6 and 1.5 or 2. this way the muzzle flash will have randomness on the brightness another module we can add is a set color over life where we need to set the composition to multiply and in the gradient we can remove these two keys and add another one more or less around here so it's brighter in the beginning and then it fades out so it doesn't disappear out of nowhere okay so the metal flash is looking nice now let's use the code we created because muzzle sometimes goes sideways depending on the weapon so i'm going to create a group selection copy with ctrl c and then paste it around here rename it to muzzle cone and change the mesh to the cone shape we have created right i'm going to slow this down in the play rate so we can see what's happening here if i turn on wireframe you will notice that the code is with the wrong rotation right and that's because we have a set angle that we can remove we don't need it if you press play now and in my case this is pointing to the opposite direction because of the negative values i have in the set size like i said a few moments earlier you don't need negative values if you rotate minus 90 degrees and the cool thing is that the set scale the z will control the depth of this metal code right now as you may notice this is how the texture is being mapped and that's normal because we want to set the uv mode to scale and bias this allows us to control the uv scale especially the x value as you can see if i insert 5 it will repeat this texture 5 times and we have this nice star that we commonly see in muzzles and then you can adjust the scale as you wish but you can also insert a random number in the x of the uv scale something between 2 and 5 for example and it will be always random which is super cool and if i bring an ak model into this we can have a better perception of how it's looking and if you think the muzzle is too big you can easily scale it now like you do with any other object now if you want to add smoke go get this texture in the link that i left in the description then with spacebar add a simple particle system you can replace the constant spawn rate with a burst of one or more particles for the velocity the x controls if it goes sideways the y is to go up or down and the z is how far the smoke goes lifetime should be something short now to use the smoke texture select flipbook blend in uv mode set the flip book size to 6 by 6 and then select the smoke texture only one frame is showing because we need to animate this texture so search for index life and choose this curve and with right click in the last key press edit and since this is 6x6 it gives 36 frames so let's set it to 35 because it starts at 0. and that's it you get a quick aftermath smoke you want to change the color use the set color but you need to change the composition of the set color of a life to multiply you want to make it brighter change the blend mode to additive you can also make the size random with a set size and we can also add randomness to the rotation with a set angle with random numbers in the z and that's it you got a nice aftermath smoke in your muzzle flash and of course the possibilities are a lot but at least you got the basics done and you can explore from there so if you enjoyed this tutorial please smash the subscribe button and leave a like i did a few variations for my patrons if you also want to spark me you can get all of these muzzles and many many many more effects for your games and projects the links in description to all my patrons these videos would not be possible without you so a big thank you goes to all of you and as usual for the top tier patrons here goes a quick shout out and they are aaron david crew tony toronto goblin plug guide lee mariah's pc hostile mars game john nix josh mccormick jules claim lars martin oytsk pandora toolbox and tk really appreciate the support of you guys thanks everyone for watching and i hope to see you in the next video
Info
Channel: Gabriel Aguiar Prod.
Views: 133,656
Rating: undefined out of 5
Keywords: unity, unity vfx, unity vfx graph, unity tutorial, tutorial, unity effects, unity special effects, unity particle system, unity particle effects, unity particle tutorial, vfx graph, vfx, unity vfx graph tutorial, unity particles, graph, unity graph, vfx graph tutorial, effect, unity muzzle, unity muzzle tutorial, muzzle, muzzle flash, unity muzzle flash, unity weapon muzzle, vfx graph muzzle, unity visual effect, unity weapon effect, muzzle effect, unity shooter, unity weapons
Id: sgBbnF3r60U
Channel Id: undefined
Length: 14min 30sec (870 seconds)
Published: Tue Nov 17 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.