Particle Effects in Unity (Sparkle effect when collecting coins)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone I want to create a nice effect when I collect a coin now the effect I'm looking for is kind of something like this here in Mario Kart you when you collect a coin that there's a bit of a sparkle so that's what I'm going try and implement the way I'm going to do this is I'm going to create a particle effect I'm going to attach that to my ship so I'm going to create a new empty object I'm going to create a particle system first thing I'm going to do is I'm going to reduce the emission reduce the speed it's okay to have very slight movement upwards I guess actually no I'm just going to reduce it all together now they're all crowding around the ship here I want them to spread out a little more so I'm going to increase the radius these particles are sticking around a little bit too long so I'm going to reduce the lifetime the emissions are a bit slow so I'm going to increase the simulation speed all right let's give this thing a material let's increase the size I don't like how they just kind of disappear it' be nicer if they fade away so I'm going to decrease the alpha here if we slow down again we can see that they're now fading away I'm going to decrease the speed a little bit maybe a little more maybe increase the rate of emission a little to create that bit of energy okay so that's the first kind of particle effect just to kind of the general Sparkle around the ship what I want to do now is I want to have kind of one big Effect one big kind of Splash right here in the middle as well I'm going to create another particle effect this particular one I just want one particle and I just want it to emit once so I'm going to go to the shape and just completely reduce it so now we just have one thing firing here in the middle but I just want it to fire once you may also notice that there's a bit of a delay here when I restart the particle before it appears I'm going to show you how I'll solve this in just a moment I'm going to increase the size of this a little bit now the next thing I would like to have is I would like to have one more thing I would like to have a few Sparkles kind of star-shaped Sparkles that kind of go up around these two particle effects so what I'm going to do is I'm going to create a custom Sprite a little star Sprite in Crea and then use this in a third particle system so let's jump over to C I'm just going to draw a very simple kind of star apply a little bit of a blur effect to this get rid of the background and Export it and import it into Unity now we're going to create a new material for a particle effect the Shader will be a particles unlit Shader the rendering mode will be addtive and our map will be our newly created texture looks pretty good time to put this thing to use in our particle effect create a new particle effect and we're going to apply our new material okay we see it's being put to use it's a bit big so we're just going to reduce the size and it's a bit too frantic so we're going to make make it a little smoother we're going to increase its lifetime a little bit and we're going to have it move up ever so slightly there we go that's looking better we're going to decrease its size a little more okay let's see what all this looks like when we put it together we are going to Define three game objects for our particle effects we're going to hang on to the actual particle system so that we just have to extract them once pull the particle system out of the game objects and down where we collect the coin we're going to play our particle systems now here is where I want to get back to one point real quick if we look at the second one here we're actually first going to turn off the looping parameter of all these systems here we don't want them to Loop we just want them to play once but the second one here this is the one where we have this delay I don't like this I don't don't like this delay if I if I hit if I call Play It will play with this delay the way to work around this that I found is instead of calling play what we're going to do here is we're going to in the particle system set the emission to zero we're basically not going to emit anything here by default and then we're going to do the emission in code so we're going to say emit one and then play if we call emit one and play the moment we call Play It Will emit right away and it will not have this delay also remember to turn off play on awake that way they don't play just in the beginning when the game starts but play when we tell them to play we're going to assign our objects here okay let's get this it go well I did see something okay I'm going to get rid of all the obstacles here now we should just be getting coins because we turn off the obstacles okay getting somewhere not quite there not quite where I want yet the whole thing is just a bit too too spread out I want it to be a bit more a little bit more focused here in the middle so let's get back to it so while working with these particle effects I like to usually have them looping hit restart here and then they just play so yeah this is just a bit too much spread here so I'm going to a shape and I'm going to just reduce it here a little bit the radius also I don't like it that it's white so I'm going to give it a different color I'm going to make it yellow and I'm going to reduce the size here just a little bit okay I'm going to reduce the duration a little bit as well okay I think this one should be all right let's have a look at the large effect here oh that's right I turn off the emission here this one could be a little bit bigger put the emission back off because we programmatically control that one and now the Stars also here that's a bit too spread so I'm just going to go to the shape just reduce the radius a little bit also going to reduce the duration just a little bit to do that I usually turn turn off the looping setting so I can see exactly how long one iteration is let's go and reduce this to three and let's try this again yeah with these particle effects it's a lot of trial and error a lot of tinkering and tweaking yeah it's getting somewhere okay I think that's that's pretty all right so one thing I don't like of course is that the particle effects clip into the ship itself so let's deal with that yeah let's deal with that and we're going to do that by working with the camera system a little bit here so I'm going to give you a quick intro into the camera system and how this is set up this camera has a stack of cameras the first camera is a post layer One camera the second a post Layer Two and on top this no processing no postprocessing camera on post layer one we have um essentially nothing but these barriers because we app apply a bloom postprocessing effect to those barriers and we currently are only applying this Bloom postprocessing effect to to these barriers and therefore we render them first in a separate camera on a separate layer then the second camera is the camera that renders the environment itself the third camera is the plane now the reason why I have these two separate is because in post layer 2 we again have a volume mask and the volume mask essentially points to this impact blur postprocessing effect that's also in post layer 2 I currently don't want when I hit the barrier the the ship itself to blur I just want the environment to blur which is why I have these two layers separate so what I can do now is I can basically create another no postprocessing camera on top of the ship on which I can render The Collection particle effects so let's create the second camera just going to copy and paste it call it no post processing 2 create another layer put his calling mask on nothing except no post two and now we can put the effects that we have here on no post 2 so very important step this camera is not being used yet so let's add it to the stack and we can see here it's not using post processing like these first two here and because this camera is layered on top of the camera that renders the ship the collection effects will be rendered over the ship there won't be any clipping it'll look like the ship is behind it let's give this a go that's definitely a lot better so one thing I don't like is that the the sparkle effect rotates along with the ship yeah I definitely don't like that I want that to remain steady and the reason why it rotates with the ship is because it's a child these affects her children of the ship itself so I'm going to pull them out into their own object and I'm going to sync their position with the position of the ship so what I'm actually going to do is I'm actually going to create a parent object here I'm going to call player and I'm going to drag the ship into this and I'm going to pull the collection particle effects out of the ship and into the player parent object and now they will no longer rotate with the ship but they will now of course also not update at all with the ship's position so what I'm going to do now instead is I'm going to attach a script to the player and the job of that script is just to synchronize the positions between these effects and the ship itself but not the rotation I'm going to add a script this script will have a list of Game objects and now in the update method I'm going to go through the list of effects and set their position to the position of the player or of the ship so I'll need one more object the player itself or rather the ship itself so I'm going to Loop through all the effects and set their position to position of the ship next next I'm going to assign the particle effects to the properties in the player script now let's try this again yeah definitely better I like that it's not rotating with the ship anymore yeah I like this this is good this turned out pretty good it still has room to improve but it's good start it's a lot more fun to collect these coins now okay thanks for watching see you next time
Info
Channel: make100games
Views: 88
Rating: undefined out of 5
Keywords: Unity 3D, Particle Effects, Particle Systems, Game Development, Tutorial
Id: 77IvdSD_oUI
Channel Id: undefined
Length: 11min 17sec (677 seconds)
Published: Mon Apr 29 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.