How To Make A Particle Gun - VRChat Udon 2023

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
how's it going today we're going to be making a particle gun this is a simple game object where when you pull the trigger it fires off some particles super easy to make and barely any code so let's get to it because there's a couple components to a particle gun let's go through its construction and steps first we're going to make the bullet particles with Trails secondly we're going to make the explosion particles third create the gun model and lastly write the udon graph script so let's head into Unity now that we're in unity go to the top left of the hierarchy and select the plus icon go to effects particle system rename your particle system to Bullet particles under its inspector set its rotation to where the particles are coming out horizontally for me I'm setting it to 0 0 0 next go to duration and set it from 5 to 20 D select looping under Start lifetime change it from 5 to 10 Under start Speed set it from 5 to 50 go to start size and change it to 0.5 go down to start color select it and choose a color you like for me I like purple so I'm going to change it to that next go to simulation space change it from local to world then go to play on awake deselect play on awake next go to emission and open it up under rate over time change it from 10 to zero then go to burst select the plus icon and change the count from 30 to 1 open up shape and change the shape from cone to box then set the scale of that box to 0 0 0 after shape go down to collisions check collision and open it up under Collision change the type from Planes to world go to bounce and set that from 1 to zero under lifetime loss change that to one after Collision go down to sub Subs select sub emitters and open it up change it from birth to death we'll leave this empty because we'll make the sub emitter a little bit later after sub emitters go down to Trails select and open it up under lifetime change it from one to 0.1 then go down to width over Trail and change that from 1 to 0.1 as well next go to the right and select the arrow facing down open it up and change it from constant to curve under the particle system curve graph select the icon that has the curve going from the upper left to the bottom right select the key and drag it over to about 4.5 and then curve it out under Trails it's asking for material we can do this in the render module open up render and we see we don't have a material for our Trail so let's make one go to assets right click create material let's rename this material to Trail material under inspector go to a Shader and change it from standard to VR chat mobile particles additive go back to your bullet particles and go to the renderer module under Trail material grab your Trail material that you just made and place it in its slot let's play the particle system now we have a functioning bullet now that we've made our bullet particles let's make our explosion particles first go to the top left of the hierarchy and select the plus icon go to effects particle system rename it two explosion particles then select bullet particles and copy the transform position data go to the top right and select the three dots copy component then select explosion top three dots and paste component values this will place both systems in the same position in the world select explosion again and change the duration from 5 to one deselect looping go to start lifetime and change it from 5 to 1 go down to start size and change it from 1 to2 then go down to simulation space and change it from local to world then go down to plan awake and deselect it next go to emission under emission change rate over time from 10 to zer go to burst hit the plus icon and change the count from 30 to 100 then go to shape and change the shape from cone to sphere go down to scale and change it to 0.1 by 0.1 by 0.1 next go to color over lifetime select it and open it up select color in the gradient editor select the first bottom Arrow hit color and choose something you like go back to the editor and drop another arrow by left clicking hit color again and choose another one you like lastly hit the last arrow and choose the third color then set the gradient to how you like it next go to size over lifetime select it and open it up select the graph then go down and click the icon where the graph goes from the top left to the bottom right next let's see how the particles look looks like a good explosion select bullet particles go to sub emitters and grab your explosion particles you just made and drop it into the submitter select yes repairing now what this should do is when we play the bowet particle it'll hit a wall using the Collision that we set and it'll end the particle at its death the explosion particle will play so let's see how it works looks pretty good now that we've made our particles let's start working on our gun model feel free to use the inbuilt 3D modeler that comes with unity already as for me I'm going to be using probuilder alongside Pro grids if you have any questions about getting these programs into your world go to icono classes create your first VR chat world series on YouTube go to his first video titled setup and at 7 minutes and 30 seconds you explains how to import the two add-ons before we begin go to PR grids and set the snap increment to .125 then go to probuilder and under new shape select the plus icon set it to q and select build then select cube in the hary and rename it to gun and then select face selection and let's begin modeling the gun next select the top face of the cube hold down shift and bring it up One Snap increment then select the left face hold down shift again and extrude two snapics and now we have a basic model of a gun next let's get the bullet particles and place them in front of the gun now just a little side note when you're putting the particles in front of the gun because both of these objects have colliders on them make sure sure they're not tooo close otherwise it'll explode on impact so let's bring it out a little bit more and there we go now that we have the particles where we want them in front of the gun let's set these particles as child objects of the gun select your gun and then go to its inspector deselect static go down to its box collider and set it to is trigger next we're going to add three components first add a VC pickup under rigid body deselect use gravity then select is kinematic go down to the script and under orientation change it from any to gun then under Auto hold change it from autodetect TOS next add a VRC object sync and lastly add a udon Behavior component now that we've made our physical gun let's start working on the logic first go to assets right click create VR chat udon udon graph program asset then let's rename the script to particle gun logic select the script and then press open Udon graph now that we're in udon graph go to the variables Tab and select the plus icon search up particle system let's rename the particle system variable to Bullet particles then select the arrow and change it to public hit compile and then grab your variable and drag it onto the graph next hit the space bar and search up custom event rename your custom event to fire gun then hit the space bar again and search up particle system under particle system search of play and select the play note next search up send custom Network event hit the space bar and select the node after that hit the space bar again and search up event and then event on pickup used down under send custom Network event change the event name to the custom event you just made which is fire gun hit compile one more time go to your scene select your gun scroll down to the udon Behavior script and drop the script you just wrote into the program Source the public variables will populate leaving a space for bullet particles so grab your bullet particles and drag them into the space let's see if it works hit [Music] play looks pretty good now that we finished our particle gun and we know that it works let's take a look at the script you may have noticed we're using a vent unpick up Ed down node coupled with a send custom Network event node the reason why we're doing that is because if we try to directly input the onp pickup used down into this play node the particle system is only going to play for you so because we want everyone to see the particles we need to network that event the way we do that is we create a custom event then we name it something in this case we called it fire gun then we create a network node and instruct the node to control the custom event titled in this case fire gun you using this tab here so every time I pull the trigger it plays the bullet particles for everybody in the instance now I'm sure you're getting it that networking is strictly an illusion because it's not that we're seeing the same particles it's strictly every time I pull the trigger it plays a particle system for you too coupled with the fact that this has a VRC object sync component on it creates the Grand Illusion that you and I are seeing the same thing but that's Network working as for our particle systems we instructed our primary system bullet particles to emit only one particle whenever the system is played then in the Collision module we instructed that particle to die whenever it hits a collider in the world then under sub emitter we instructed it so that every time that particle dies it plays our explosion particle system like so and that's pretty much it thank you so much for your time and I hope this video was helpful to you see you on the next one
Info
Channel: myneighborswifi
Views: 809
Rating: undefined out of 5
Keywords:
Id: Sl4PpFpMcAM
Channel Id: undefined
Length: 16min 34sec (994 seconds)
Published: Thu Oct 19 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.