How To Create and Shoot a 2D Laser in Unity

  Рет қаралды 90,366

Gabriel Aguiar Prod.

Gabriel Aguiar Prod.

Күн бұрын

Пікірлер: 190
@GabrielAguiarProd
@GabrielAguiarProd 4 жыл бұрын
Pew! Pew! Who doesn't love lasers!!! Hey check out the game working in, that would be awesome: store.steampowered.com/app/1763860/Rabbits_Tale/
@26keremalpdemir88
@26keremalpdemir88 10 ай бұрын
IMPORTANT: To remove the black background from the laser in newer versions of unity, in the last node you have to draw a line to "Base Color" and also to "Alpha".
@razlubinsky
@razlubinsky 5 ай бұрын
how
@himeyuxi7125
@himeyuxi7125 5 ай бұрын
@@razlubinsky​​⁠ ​​⁠take the Out(4) of the last multiply node at 3:44 to Base Color (3) and also to the Alpha(1) of the Fragment node at the end of the process The Fragment Node isn’t in the video cuz it is a previous version
@himeyuxi7125
@himeyuxi7125 5 ай бұрын
Quick question friend I did that But now my laser beam can just not be green or blue anymore as soon as I do that, do you know why ? Also the little icon that shows how the shader will look in the project doesn’t look like in the video There is a cut in the middle
@mohamedmusthafa1057
@mohamedmusthafa1057 3 ай бұрын
Thanks Mate U saved My time❤
@Brecken_Nicholes
@Brecken_Nicholes 2 ай бұрын
@@himeyuxi7125 There is actually a better way than connecting the node to alpha. This will also let you color the laser however you'd like, blue and green included. Go into the graph and go to the master settings. You should see something called blending mode. Set this to additive. That should fix your issue.
@maximelnikov8568
@maximelnikov8568 8 ай бұрын
Solving the problem of crazy glow in a 3d scene in play mode: If you get a full-screen glow in the play mode, and everything is fine in the scene view, then try adding a Clamp node (min 0, max 1) after the final gradient node (between Power and Multiply). A wonderful lesson, thank you! Still relevant in 2024! I'm using this in a 3d scene in Unity 2022.3.14f1.
@andreymarkushin7361
@andreymarkushin7361 3 жыл бұрын
Unversal Pipeline Render, Custom Shaders, Mouse Controls, Particles - all in 20 minutes! Gabriel, you are awesome! Thanks a lot!
@jamez0r
@jamez0r 3 жыл бұрын
Quick Tip - not sure if it is mentioned in the video but if you want to be able to change the length of the laser without it looking like its getting stretched/squished (along the length of the laser), then change the "Texture Mode" to "Tile" on your Line Renderer
@gustbraga2736
@gustbraga2736 3 жыл бұрын
Great video! Just want to say that if u are having problems with the bloom post processing effect not affecting the laser in game view, just make sure you have the HDR set to true under your Quality section int the URP asset that you created. Lost 1h trying to debug every aspect of the shader and other things, hope this helps someone with the same problem...
@GabrielAguiarProd
@GabrielAguiarProd 3 жыл бұрын
Thanks for the tip!
@himeyuxi7125
@himeyuxi7125 5 ай бұрын
Un the video he seems to use a profile that he probably made before I just have an empty slot there so it has no effect but there is nothing to change Is it due to a newer version of Unity or am I supposed to do something before ?
@Abken.
@Abken. 3 жыл бұрын
The channel has amazing videos, but this one is probably my favorite. It shows very simple usage of shadergraph, but very effective with an amazing results. The only one thing I would've changed is the laser having a static length of X instead of the mouse position, which should be a little more simply to write in code and more realistic for a game. But again, amazing video
@GabrielAguiarProd
@GabrielAguiarProd 3 жыл бұрын
Glad you enjoy it!
@Abken.
@Abken. 3 жыл бұрын
@@GabrielAguiarProd Yeah. Keep up the great work! I will buy your Udemy course soon. I feel like your course can finally teach me how to be good and thoughtful with the VFX! Do you have any 2D videos in your Udemy course or is it exclusively for 3D (which is also fine)?
@GabrielAguiarProd
@GabrielAguiarProd 3 жыл бұрын
Mostly 3D, but there's a few 2D specific kzbin.info/aero/PLpPd_BKEUoYj9LEKgYeemilQLwqrJJ_Mf
@onomi-
@onomi- Жыл бұрын
if anyone is struggling with the bloom effect, try changing the intensity value of the HDR value of your line renderer's material, and if bloom isnt applied in the game view make sure that your camera has "Post Processing" checked
@GabrielAguiarProd
@GabrielAguiarProd Жыл бұрын
Awesome tip, thanks for sharing with the community! 👍
@himeyuxi7125
@himeyuxi7125 5 ай бұрын
Un the video he seems to use a profile that he probably made before I just have an empty slot there so it has no effect but there is nothing to change Is it due to a newer version of Unity or am I supposed to do something before ?
@martinmica4260
@martinmica4260 2 жыл бұрын
Thank you so much! I really do appreciate how you explain everything you're doing! (I finally get the raycasting for example)
@GabrielAguiarProd
@GabrielAguiarProd 2 жыл бұрын
Fantastic!
@serj_1264
@serj_1264 4 жыл бұрын
Another great tutorial by Gabriel Aguiar! Doesn't matter when you read this. Thanks!
@N301
@N301 Жыл бұрын
Nice Tutorial Gabriel! Thank you.
@GabrielAguiarProd
@GabrielAguiarProd Жыл бұрын
My pleasure!
@LimitedBits
@LimitedBits 7 ай бұрын
Learned so much from this, thanks!
@rezmerz9235
@rezmerz9235 4 жыл бұрын
Hi there, Thanks for tutorial but I get this error: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them and material/shader is not working ( the line dissapears)
@pinestark
@pinestark 3 жыл бұрын
I think it's because the color isn't set to hdr. I got the same error and it disappeared once i did that.
@demonicbane6499
@demonicbane6499 2 жыл бұрын
Hey man, this was great. Thanks :) Too much fantastic information in 20 minutes
@GabrielAguiarProd
@GabrielAguiarProd 2 жыл бұрын
My pleasure! Glad you liked it :)
@munchymcmouthington298
@munchymcmouthington298 2 жыл бұрын
Thanks for this, had a slightly different use-case but it gave me what I needed to figure the rest out :)
@GabrielAguiarProd
@GabrielAguiarProd 2 жыл бұрын
Great to hear!
@Only4GamersXyz
@Only4GamersXyz 3 жыл бұрын
Hello, I am using forward renderer instead of 2d renderer. Everything is working fine but whenever i am firing laser whole game screen becoming very bright. But in scene screen everything is looking fine. Other users are also having similar problem. Please help. Thanks
@GabrielAguiarProd
@GabrielAguiarProd 3 жыл бұрын
I don't know why this is happening. But have you tried to decrease the intensity of the laser color? Mayb also decrease the Bloom (if you have any)?
@Only4GamersXyz
@Only4GamersXyz 3 жыл бұрын
@@GabrielAguiarProd Thanks for the reply. I solved this problem by using clamp in my Bloom. But I have a different problem, please help me to solve this problem. I am getting dotted lines in both sides of the laser. kzbin.info/www/bejne/g5OYmpmAgZxnprs Please tell me how to fix this. Thanks
@familyfriendlycontent.jayp1944
@familyfriendlycontent.jayp1944 3 жыл бұрын
This is just what I needed, thank you!!
@alex2d324
@alex2d324 4 жыл бұрын
Wow! 2D Renderer! At last! :)))) BI-I-IG Thanks! :)
@GabrielAguiarProd
@GabrielAguiarProd 4 жыл бұрын
You're welcome! I've got a few more on my channel
@kalibeastok
@kalibeastok 3 жыл бұрын
Hey! Awesome, thanks for sharing! Everything went ok, but I want to know how I can remove the black background from the laser line renderer? In the parts of my level where the light is brighter the black background is very noticeable.
@pidly
@pidly 3 жыл бұрын
This is kinda old now so not sure if you figured it out but I had the same problem in a newer version of unity. In the last node you have to draw a line to "Base Color" and also to "Alpha". I think alpha used to be lumped in with all the colors.
@augustrothpletz7932
@augustrothpletz7932 3 жыл бұрын
@@pidly Thanks so much!
@himeyuxi7125
@himeyuxi7125 5 ай бұрын
@@pidlyi did so and it worked But I have an issue now bc when I set the color to green or blue it just disappear But no problem with purple yellow or red I have no idea why this is occurring
@JB-iz8bi
@JB-iz8bi 4 жыл бұрын
Great tutorial!
@m0u5tafa
@m0u5tafa 2 жыл бұрын
great video just wanna mention that this works step by step in unity 2020 but there are some problems in unity 2021 if you wanna follow this video step by step it's better to use unity 2020
@hroluffy8974
@hroluffy8974 Жыл бұрын
Yes. Do you know the solution?
@vazquelol3097
@vazquelol3097 4 жыл бұрын
Amazing! Thanks
@NoeliusMax
@NoeliusMax Жыл бұрын
How did you manage to make the bloom only affect the laser beam? I created the object successfully but it makes everything on the scene to emit light. Thanks for the video!
@GabrielAguiarProd
@GabrielAguiarProd Жыл бұрын
Well the Bloom here is not affecting only the Laser. It might seem like it, but it's just a global volume with a profile that has bloom :) But I believe you can make volumes only work on for a specific layer perhaps, which means the VFX would be on one layer and volume would only affect that layer.
@NoeliusMax
@NoeliusMax Жыл бұрын
@@GabrielAguiarProd Thanks for the fast reply! It was my fault, I didn't realize but the configuration i set up for the URP was wrong. 😅 Yeah, now i've been able to make the bloom or other effects only apply on specific layers. Thanks a lot for your help and you video.
@ksong5589
@ksong5589 9 ай бұрын
great video! But, How to make the rainbow Laser when shot, the rainbow color moving to target repeatedly?
@Maddogs1
@Maddogs1 3 ай бұрын
The position of the laser seems to only update every 0.3 seconds or so rather than every frame, any idea why?
@spontaneousquirk6670
@spontaneousquirk6670 4 жыл бұрын
If you try this in a 3d scene, make sure to clamp the powered gradient between 0 and 1, or you might get some CRAZY bloom
@Only4GamersXyz
@Only4GamersXyz 3 жыл бұрын
Hello, What is powered gradient? Power node Inside shader graph? Which power node?
@jonas14812
@jonas14812 2 жыл бұрын
Amazing video, thank you so much!💪
@GabrielAguiarProd
@GabrielAguiarProd 2 жыл бұрын
No problem 👍
@huynguyenphan4120
@huynguyenphan4120 Жыл бұрын
Amazing. Thanks
@shinebatganbat4816
@shinebatganbat4816 Жыл бұрын
Great video mine doesn't have unlit in universal render pipeline/particles what could it be forgotten?
@BlueGooGames
@BlueGooGames 4 жыл бұрын
This is excellent! Now I just need to figure out how to use this in Space Chef 😀 i think some kind of portable mining laser..
@GabrielAguiarProd
@GabrielAguiarProd 4 жыл бұрын
That would be cool!
@AdidasDoge
@AdidasDoge 2 жыл бұрын
Why does other parts of your scene not light up when you are using the bloom? Your bloom value is extremely high. How is the gun and scene not lighting up?
@jonas14812
@jonas14812 2 жыл бұрын
Maybe u set the Threshold value to < 0.9, then everything else lights up as well
@jeremyb2120
@jeremyb2120 9 ай бұрын
Can you use a 2d renderer in a 3d game? My game's in 3d, top down, but I need a laser like this still. Any suggestions?
@GabrielAguiarProd
@GabrielAguiarProd 9 ай бұрын
Perhaps try combining it with this one: kzbin.info/www/bejne/lYTEc4uPYqqdp9E
@baichuanouyang3259
@baichuanouyang3259 Жыл бұрын
How would i go about having this detect if it collides with a gameobject with a certain tag? Currently, the raycast is going through all walls and not being blocked
@MrHwizard
@MrHwizard 4 жыл бұрын
Ref should be "_MainTex" not "MainTex_"
@joaocarlosp.p.6550
@joaocarlosp.p.6550 2 жыл бұрын
How to do with static movement and without the mouse? Please make one for this I really need it for my game and I can't find a better one, I'm new to programming.
@himeyuxi7125
@himeyuxi7125 5 ай бұрын
Thank you for it but I have some issue with the tutorial Firstly some stuffs has changed in Unity with time so I had to guess how to do some stuffs that were not like in the video But as someone said in the comment I linked the last multiply to the Alpha to remove the black background But it also has the effect to prevent me from making the color to green or blue Like I can make the laser red or yellow But not green or blue It makes it fully disappear Also the shader icon the my project doesn’t look the same as yours Mine seems cut in the middle but I can’t figure why I hope someone here can help me 😅 Hnd
@Afestolen
@Afestolen 5 ай бұрын
Add Global Volume to your project. Google Unity: How To Add Bloom In URP
@wellingtonipf
@wellingtonipf 4 жыл бұрын
Sugestão de pauta: poderia fazer um shader 3d de deserto, estilo journey? Onde ficam as pegadas e as areais se movem com o vento. Fã do seu trabalho! :D
@niagmest
@niagmest 2 жыл бұрын
Awesome video
@GabrielAguiarProd
@GabrielAguiarProd 2 жыл бұрын
Thanks!
@Vasquez2701
@Vasquez2701 2 жыл бұрын
Whatever I do, my laser doesn't glow or increase its thickness with the value, it gets stuck in a rectangle and it looks as it was a stretched sprite
@nothingatall6703
@nothingatall6703 2 жыл бұрын
Did u find a solution about the thickness, I can not increase too
@Vasquez2701
@Vasquez2701 2 жыл бұрын
@@nothingatall6703 not really. I paid the Patreon and never got a response. However, I realized that you need a light multiplier, and your sprites have to be lit with a darker color (set them to gray-black) in order for this multiplier to affect only the ray itself. I forgot the name of the multiplier, but he adds it on this tutorial
@yuvibarbash
@yuvibarbash 5 ай бұрын
Great Stuff how do i create this as a pixel art?
@nothingatall6703
@nothingatall6703 2 жыл бұрын
I have a warning which says "MaterialPropertyBlock is used to modify these values ". Is this the reason that I can not make the laser thicker and if it is, can u please help me
@komamon5566
@komamon5566 4 жыл бұрын
Can you make electricity using this method?
@LePetit2
@LePetit2 3 жыл бұрын
I don't know how you make the laser look that blurred and brighten. I just get the texture to work.
@kendraw8445
@kendraw8445 3 жыл бұрын
I have the laser working great, but I cannot for the life of me figure out why I cannot get the VFX to show up. I did not see you drag the parent VFX objects into script locations, does FillLists populate those?
@GabrielAguiarProd
@GabrielAguiarProd 3 жыл бұрын
Yes drag and drop 'StartVFX' and 'EndVFX' to their respective variables in the 'Laser' script. 'FillLists' will add the particle systems parented to those gameobjects ('StartVFX' and 'EndVFX') to the 'particles' list. Then 'EnableLaser 'and 'DisableLaser' functions will play or stop all the particle systems in the 'particles' list.
@benfau9992
@benfau9992 3 жыл бұрын
Hello, I've encounter a problem on the bloom effet. In deed, the bloom himself work, but when I press play, the bloom is going crazy and makes lot of flash if my character move, or if I try to manually move or rotate the laser. However, it is going back to normal when my character stops himself. Does anyone have a solution for this weird bug?
@bukaanka
@bukaanka 3 жыл бұрын
Have you found a soultion to this by any chance? Experiencing the same issue :c
@scyan897
@scyan897 2 жыл бұрын
This comment is super old but just go to your particle material and change the intensity on the HDR color space
@Brecken_Nicholes
@Brecken_Nicholes 2 ай бұрын
Does this only work in URP? I already have a non URP project created.
@Brecken_Nicholes
@Brecken_Nicholes 2 ай бұрын
Oh, also I sent you an email. Would you possibly be able to respond to that?
@loeckm
@loeckm 3 жыл бұрын
For some reason when I add that last multiply node to the shader graph and connect to Color/SpritLitMaster the line doesn't show up anymore and the Main preview goes grey in SG. If I don't add that last Multiple node and directly connect the power node to the color it shows up. Any ideas?
@techstorm.3461
@techstorm.3461 3 жыл бұрын
Yo, how (and could I) could I use this as some kind of attack for my platformer game?
@rishabh999100
@rishabh999100 4 жыл бұрын
U r awesome 😀👍
@sreejithkakkat
@sreejithkakkat 3 жыл бұрын
Will it work on mobiles without much processing
@shobhitsahu5878
@shobhitsahu5878 Жыл бұрын
What to do if i want only the direction of line renderer to be in the direction of mouse but length of line renderer will be predifined and only if raycast hits the end position becomes hit position?
@neozoid7009
@neozoid7009 2 жыл бұрын
Awesome
@Lost1nTranslation
@Lost1nTranslation 4 жыл бұрын
At 5:51, when I increase the line width, the glow flickers from small to large and back to small really quickly. This also happens when I adjust the size of the Game Screen. It doesn't appear to have happened to you. Do you know why this happens? Thank you! Great tutorial btw!
@GabrielAguiarProd
@GabrielAguiarProd 4 жыл бұрын
Bloom too high maybe? Dunno
@Lost1nTranslation
@Lost1nTranslation 4 жыл бұрын
@@GabrielAguiarProd I will try and lower the bloom. Maybe its a bug as well. Thank you!
@agustin9594
@agustin9594 4 жыл бұрын
In my game the laser looks horrible, where i can get a tutorial for configure universal render pipeline?
@viniciustadeumonteirosacco1002
@viniciustadeumonteirosacco1002 3 жыл бұрын
Hello, Congratulations for another great video. I am a beginner in unity development, I followed his example, but the black part of the shader was not transparent. Can you help me?
@GabrielAguiarProd
@GabrielAguiarProd 3 жыл бұрын
Maybe set the shader blend mode to Additive?
@scihum4985
@scihum4985 3 жыл бұрын
@@GabrielAguiarProd can you tell me how to do this. Thanks in advance.
@pidly
@pidly 3 жыл бұрын
I think in newer versions of Unity they break alpha out of the color so in the last node you have to make a line to color AND alpha.
@Henry-lo2xe
@Henry-lo2xe 3 жыл бұрын
2 problems, Problem1: SOLVED problem2: endVFX is just a little to the right of the mouse and I cant seem to stop it. does someone know the solution?
@binhlequocthanh9125
@binhlequocthanh9125 4 жыл бұрын
you're the best
@seraph1007
@seraph1007 3 жыл бұрын
Hi, when I add the LineRenderer, the line is completely black and does not change when I change the color settings. I can't figure out what I'm missing
@its_holtzzy
@its_holtzzy 2 жыл бұрын
have you added any lights to your scene? its a lit shader, so needs lighting
@kartheekvajrala2487
@kartheekvajrala2487 3 жыл бұрын
my laser is working without any background but if I put a background image/sprite the laser disappears and I even checked the layers correctly and laser is in foreground. Any HELP?
@kalibeastok
@kalibeastok 3 жыл бұрын
check if you have Universal Pipe Renderer assigned.
@elithevil
@elithevil 3 жыл бұрын
How to disable global bloom for weapon and other things except the laser line?
@HalfTangible
@HalfTangible Жыл бұрын
I can make the material and apply it to the line renderer, but all it does is make a line with black edges. Did I miss something in creating the materials?
@xuanthinhang7883
@xuanthinhang7883 Жыл бұрын
Try setting the shader blending mode to additive in Graph Inspector -> Universal -> Blending mode. Setting it to additive fixed it in my case
@HalfTangible
@HalfTangible Жыл бұрын
@@xuanthinhang7883 Yessir, that fixed it real easy, much obliged! ^_^ Now I have a proper laser
@jaulloa21
@jaulloa21 3 жыл бұрын
Hi, I can’t get the glow effect. I’m using unity 2021. I don’t have the master sprite tool
@qwwongs33
@qwwongs33 3 жыл бұрын
same here, did you solved that?
@holtras8786
@holtras8786 3 жыл бұрын
Please tell me why my line from line renderer is completely no smooth. Its look so bad
@eduarddebruyn4841
@eduarddebruyn4841 4 жыл бұрын
When I change the Index X under Positions, it creates a circle, not a line? I followed all your steps to the letter, what could be the issue?
@eduarddebruyn4841
@eduarddebruyn4841 4 жыл бұрын
I figured it out. had to change the default material to Sprite Lit Default
@sumitcutevil9260
@sumitcutevil9260 2 жыл бұрын
hey sir my laser thickness is not increased in line renderer what can i do?? i did all the things.....as per you...the laser intensity increased but not laser thickness since unity 2021 has no vector 1 i used float instead...can yu please help me out sir?
@nothingatall6703
@nothingatall6703 2 жыл бұрын
Did u find a solution , Im having the same problem
@Brecken_Nicholes
@Brecken_Nicholes 2 ай бұрын
@@nothingatall6703 Adjust the width in the line renderer. You should see a red line. The biggest number on the red line will be 0.10. Click that and type in a larger number.
@mmmmmno-mm2vw
@mmmmmno-mm2vw 4 жыл бұрын
After I apply the material, I don't get any options to "play with". My Material is just white and nothing happens
@GabrielAguiarProd
@GabrielAguiarProd 4 жыл бұрын
Don't forget to save your shader. Press Save Asset in Shader Graph, top left corner.
@Ascadey
@Ascadey 4 жыл бұрын
At 4:36 am, when I try to adjust the parameter "LaserThickness", this glow does not occur, please help, thanks!
@GabrielAguiarProd
@GabrielAguiarProd 4 жыл бұрын
I have a Global Volume with Bloom, that's why It glows like that :)
@Ascadey
@Ascadey 4 жыл бұрын
@@GabrielAguiarProd Thank you, but it turns out I had to turn on the camera parameter "post-processing" to make everything work)
@GabrielAguiarProd
@GabrielAguiarProd 4 жыл бұрын
@@Ascadey Yeah sometimes I forget that part too :)
@11hilas
@11hilas 3 жыл бұрын
How do i make a Beam like in 20:53 ? I just bought the Project but a cant find it.
@GabrielAguiarProd
@GabrielAguiarProd 3 жыл бұрын
Please look closely, I'm sure it's there. Check the prefabs folder, or maybe in the scene attached to another object (can't remember where).
@nothingatall6703
@nothingatall6703 2 жыл бұрын
The thickness of the laser doesnt really change its size, can u please help
@himeyuxi7125
@himeyuxi7125 5 ай бұрын
Increasing it doesn’t change much But decreasing the value until it gets negative thickens it
@prietinho6690
@prietinho6690 3 жыл бұрын
my glow effect doesn't affect to the laser line, do you know why?
@manishsuresh13
@manishsuresh13 3 жыл бұрын
Try saving the shader asset, if you have not
@meatyourhouseatnight
@meatyourhouseatnight 4 жыл бұрын
Not sure why but cant seem to get the same amount of glow as you're getting,
@KebUP
@KebUP 3 жыл бұрын
i think its after post process effects so its more glowy.
@emiralbayrak7078
@emiralbayrak7078 Жыл бұрын
Hi thx for the video but my black part is not transparent
@GabrielAguiarProd
@GabrielAguiarProd Жыл бұрын
Make sure your texture doesn't have a black background.
@ntomsho4545
@ntomsho4545 Жыл бұрын
@@GabrielAguiarProd What texture? It's just the UV map. How do you remove the black background?
@sharpedged7830
@sharpedged7830 3 жыл бұрын
Cool tutorial, but my laser flickers randomly every now and then (There are very bright circles at some random point on the laser), anyone knows a fix?
@freestylerak6655
@freestylerak6655 Жыл бұрын
i was having the same problem, only solution i found is, clamp the power node in shader graph between any 2 values. i have clamped between 7 & 8. Smaller the range the less it will flicker so keep the range small so flickring will become unnoticable.
@sharpedged7830
@sharpedged7830 Жыл бұрын
@@freestylerak6655 I fixed it by lowering the bloom "clamp" value to something reasonable.
@12a2-nguyenduy8
@12a2-nguyenduy8 4 жыл бұрын
when i created Global Volume, i can find bloom to add , help :((
@meatyourhouseatnight
@meatyourhouseatnight 4 жыл бұрын
Hey brother, incase you/Anyoneelse hasnt figured it out yet, package manager -> install post processing ->in your global volume add a new profile if you dont already have one ->Go to that profile (by clicking on it) and click "Add Override" ->Postprocessing ( you just installed it ) -> bloom etc
@12a2-nguyenduy8
@12a2-nguyenduy8 4 жыл бұрын
@@meatyourhouseatnight omg , i'm newbie so i dont know about it . Thank to you , now i can create it. Tks a lots.
@meatyourhouseatnight
@meatyourhouseatnight 4 жыл бұрын
@@12a2-nguyenduy8 glad i could help. :')
@12a2-nguyenduy8
@12a2-nguyenduy8 4 жыл бұрын
@@meatyourhouseatnight you're great, can i connect with you , i'm still noob :(((
@sungerbob1786
@sungerbob1786 4 жыл бұрын
what about some realistic effects? instead of these cartoony stuff?
@GabrielAguiarProd
@GabrielAguiarProd 4 жыл бұрын
There's a few on my channel that lean a bit more towards the realistic side of things. Enjoy.
@sungerbob1786
@sungerbob1786 4 жыл бұрын
@@GabrielAguiarProd thanks. i will check them.
@myunity8488
@myunity8488 2 ай бұрын
using System.Collections; using System.Collections.Generic; using UnityEngine; using static UnityEngine.ParticleSystem; public class LaserTut : MonoBehaviour { public Camera cam; public LineRenderer lineRenderer; public Transform firePoint; public GameObject startVFX; public GameObject endVFX; private Quaternion rotation; private List particleSystems; void Start() { FillLists(); DisableLaser(); } void Update() { if (Input.GetButtonDown("Fire1")) { EnableLaser(); } if (Input.GetButton("Fire1")) { UpdateLaser(); } if (Input.GetButtonUp("Fire1")) { DisableLaser(); } RotateToMouse(); } void EnableLaser() { lineRenderer.enabled = true; // Add additional logic if needed, e.g., start VFX for (int i = 0; i < particleSystems.Count; i++) particleSystems[i].Play(); } void UpdateLaser() { var mousePos = (Vector2)cam.ScreenToWorldPoint(Input.mousePosition); lineRenderer.SetPosition(0, firePoint.position); lineRenderer.SetPosition(1, mousePos); Vector2 direction = mousePos - (Vector2)transform.position; RaycastHit2D hit = Physics2D.Raycast((Vector2)transform.position, direction.normalized, direction.magnitude); if (hit) { lineRenderer.SetPosition(1, hit.point); // Add logic for endVFX or other actions on hit } } void DisableLaser() { lineRenderer.enabled = false; // Add additional logic if needed, e.g., stop VFX for (int i = 0; i < particleSystems.Count; i++) particleSystems[i].Stop(); } void RotateToMouse() { Vector2 direction = cam.ScreenToWorldPoint(Input.mousePosition) - transform.position; float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg; rotation.eulerAngles = new Vector3(0, 0, angle); transform.rotation = rotation; } void FillLists() { for (int i = 0; i < startVFX.transform.childCount; i++) { var ps = startVFX.transform.GetChild(i).GetComponent(); if (ps != null) particleSystems.Add(ps); } for (int i = 0; i < endVFX.transform.childCount; i++) { var ps = endVFX.transform.GetChild(i).GetComponent(); if (ps != null) particleSystems.Add(ps); } } /* void FillLists() *//* { // Example method to populate particleSystems or other lists if needed particleSystems = new List(); // Add your particle systems here }*/ }
@Brecken_Nicholes
@Brecken_Nicholes 2 ай бұрын
You are my new favorite person.
@Brecken_Nicholes
@Brecken_Nicholes 2 ай бұрын
Do you have a method of turning off the VFX? I don't know how to lol.
@andytorres5721
@andytorres5721 29 күн бұрын
dawggg you saved me so much time!
@botansahin
@botansahin 3 жыл бұрын
I wrote exactly the same code, but my line goes to middle of screen? Whyy?
@SierraDyne_
@SierraDyne_ 3 жыл бұрын
mine too
@botansahin
@botansahin 3 жыл бұрын
@@SierraDyne_ You need to change your camera setting to ortographic. If you want to keep it perspective, you need to change mouse Input code in your script.
@SierraDyne_
@SierraDyne_ 3 жыл бұрын
@@botansahin thanks. Any idea as to why i cant aim the laser up without it going thin?
@botansahin
@botansahin 3 жыл бұрын
@@SierraDyne_ I dont know I didnt have this issue. İf you have bloom, it might be because of lights.
@SierraDyne_
@SierraDyne_ 3 жыл бұрын
Botan Şahin hm, i have bloom except i dont think its that
@HUBTESLA
@HUBTESLA 4 жыл бұрын
Hello. Thank you for the tutorial but it's not working for me, and i don't understand why. As you can see here imgur.com/a/Sp4O271 my shader is transparent at the end when i connect the last node to "Color". Can you help me please ? thanks
@GabrielAguiarProd
@GabrielAguiarProd 4 жыл бұрын
Increase the Alpha in the color.
@vladionete932
@vladionete932 3 жыл бұрын
The particles are never played out.
@botansahin
@botansahin 3 жыл бұрын
why my linerenderer goes to the middle of the screen?
@notarshiaj
@notarshiaj 3 жыл бұрын
You need to uncheck "World Space" in your Line Renderer settings.
@kaleb_t4818
@kaleb_t4818 3 жыл бұрын
it would be nice if u had released the project on github
@ruisenior7778
@ruisenior7778 3 жыл бұрын
Yeaaah
3 жыл бұрын
Do anyone knows how to reflect the laser????
@evanraab2104
@evanraab2104 2 жыл бұрын
anyone have a script for this to automate this laser via a timer (trying to have an enemy AI fire the laser instead of the player). Any help would be greatly appreciated!
@GabrielAguiarProd
@GabrielAguiarProd 2 жыл бұрын
Use a Coroutine for example. Google it, they are quite easy to implement. Hope this helps.
@evanraab2104
@evanraab2104 2 жыл бұрын
@@GabrielAguiarProd thanks! I considered that - my real question is where in the Updateloop would I implement the EnableLaser(), DisableLaser(), and UpdateLaser() functions, since I will not be using the getkey inputs to trigger the laser?
@evanraab2104
@evanraab2104 2 жыл бұрын
nvm, you were right, the coroutine works great! thank you!
@ssoltani498
@ssoltani498 4 жыл бұрын
Thanks for the video but the background music is loud and annoying.
@GabrielAguiarProd
@GabrielAguiarProd 4 жыл бұрын
Thankfully it’s only in the beginning and in the end. It goes away after a while. Stay well, enjoy.
@SierraDyne_
@SierraDyne_ 3 жыл бұрын
download link?
@ghfgh_
@ghfgh_ 9 ай бұрын
want to add this but need to switch to URP ahhhhhhh
@freestylerak6655
@freestylerak6655 Жыл бұрын
why my raycasting not working
@GabrielAguiarProd
@GabrielAguiarProd Жыл бұрын
Not sure but have you tried to see if it outputs something with Debug.Log() every time you are checking if it has collided? Or maybe it colliding with your "character" before colliding with anything in the scene?
@freestylerak6655
@freestylerak6655 Жыл бұрын
@@GabrielAguiarProd Thankyou. I used layermask to avoid other objects then it worked.
@mentallyunprepared8635
@mentallyunprepared8635 2 жыл бұрын
this made Unity crash, my pc and visual studio, then all scripts invalid and permanent error when starting anything new on Unity Hub lol
@TheCheldthorpe
@TheCheldthorpe 4 жыл бұрын
Shame you only used mouse input not everyone uses a mouse there is such a thing as a gamepad & why not use the new input system if using 2020.1 But 99% of youtubers forget or ignore us gamepad users.
@drewlevithan9411
@drewlevithan9411 3 жыл бұрын
at least tell which fricking template to open up first
@GabrielAguiarProd
@GabrielAguiarProd 3 жыл бұрын
At least don't skip the 0:40 part
@drewlevithan9411
@drewlevithan9411 3 жыл бұрын
Oh my gawd I am so stupid. Sorry for the rudeness. I am just frustrated I have been trying to learn this from morning. I am so sorry.
@GabrielAguiarProd
@GabrielAguiarProd 3 жыл бұрын
It's fine, no problem :) Sometimes learning can be a frustrating process. What matters is to never give up. Good luck and stay well.
@drewlevithan9411
@drewlevithan9411 3 жыл бұрын
@@GabrielAguiarProd thanks so much. Same to u and again sorry.
@SierraDyne_
@SierraDyne_ 3 жыл бұрын
download link?
@GabrielAguiarProd
@GabrielAguiarProd 3 жыл бұрын
It's in the description. Here: www.patreon.com/posts/unity-2d-laser-39800075 or in gap site: www.gabrielaguiarprod.com/product-page/unity-2d-lasers-project
@SierraDyne_
@SierraDyne_ 3 жыл бұрын
@@GabrielAguiarProd Oh sorry I didn't know it costed money- I might get it in the future but when I use the URP, my bloom on my camera turns off and the 3d models in my 2d game turn pink
Unity VFX & Shader Graph - Warp Drive / Hyperspace Effect Tutorial
21:25
Gabriel Aguiar Prod.
Рет қаралды 37 М.
Shader graph в Unity! Проще чем кажется! Шейдер граф
12:48
Яковлев Илья - IT и игры
Рет қаралды 31 М.
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,9 МЛН
Triple kill😹
00:18
GG Animation
Рет қаралды 17 МЛН
Wait… Maxim, did you just eat 8 BURGERS?!🍔😳| Free Fire Official
00:13
Garena Free Fire Global
Рет қаралды 8 МЛН
Who's spending her birthday with Harley Quinn on halloween?#Harley Quinn #joker
01:00
Harley Quinn with the Joker
Рет қаралды 12 МЛН
Unity VFX Graph - Stylized Laser Beam Tutorial
20:27
Gabriel Aguiar Prod.
Рет қаралды 81 М.
Unity VFX Tutorial - Chain Lightning Effect
17:59
Gabriel Aguiar Prod.
Рет қаралды 8 М.
The biggest lie in video games
15:18
AIA
Рет қаралды 2,1 МЛН
Making a pawn that can actually turn into a queen | Blender 4.0
12:43
How Games Fake Water
22:52
Acerola
Рет қаралды 215 М.
Unity VFX Graph - Lightning Shader Effect Tutorial
16:44
Gabriel Aguiar Prod.
Рет қаралды 133 М.
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 4,2 МЛН
Outline Post Process in Unity Shader Graph (URP)
8:24
Daniel Ilett
Рет қаралды 47 М.
The Strange Graphics Of LETHAL COMPANY
15:59
Acerola
Рет қаралды 917 М.
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,9 МЛН