How To Create and Shoot a 2D Laser in Unity

Поделиться
HTML-код
  • Опубликовано: 24 ноя 2024

Комментарии • 191

  • @GabrielAguiarProd
    @GabrielAguiarProd  4 года назад +5

    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 11 месяцев назад +34

    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 6 месяцев назад

      how

    • @himeyuxi7125
      @himeyuxi7125 6 месяцев назад +2

      @@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 6 месяцев назад

      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 4 месяца назад

      Thanks Mate U saved My time❤

    • @Brecken_Nicholes
      @Brecken_Nicholes 3 месяца назад

      @@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 месяцев назад +2

    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 года назад +7

    Unversal Pipeline Render, Custom Shaders, Mouse Controls, Particles - all in 20 minutes! Gabriel, you are awesome! Thanks a lot!

  • @gustbraga2736
    @gustbraga2736 3 года назад +8

    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 6 месяцев назад

      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 ?

  • @jamez0r
    @jamez0r 3 года назад +12

    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

  • @onomi-
    @onomi- Год назад +7

    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  Год назад +1

      Awesome tip, thanks for sharing with the community! 👍

    • @himeyuxi7125
      @himeyuxi7125 6 месяцев назад

      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 года назад +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 года назад +1

      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 года назад +1

      Mostly 3D, but there's a few 2D specific ruclips.net/p/PLpPd_BKEUoYj9LEKgYeemilQLwqrJJ_Mf

  • @serj_1264
    @serj_1264 4 года назад +2

    Another great tutorial by Gabriel Aguiar!
    Doesn't matter when you read this.
    Thanks!

  • @looty20-q8q
    @looty20-q8q 3 года назад +3

    Thank you so much! I really do appreciate how you explain everything you're doing! (I finally get the raycasting for example)

  • @N301
    @N301 Год назад +3

    Nice Tutorial Gabriel! Thank you.

  • @LimitedBits
    @LimitedBits 7 месяцев назад +1

    Learned so much from this, thanks!

  • @munchymcmouthington298
    @munchymcmouthington298 2 года назад +2

    Thanks for this, had a slightly different use-case but it gave me what I needed to figure the rest out :)

  • @rezmerz9235
    @rezmerz9235 4 года назад +9

    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.

  • @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

  • @spontaneousquirk6670
    @spontaneousquirk6670 4 года назад +1

    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?

  • @demonicbane6499
    @demonicbane6499 2 года назад +1

    Hey man, this was great. Thanks :) Too much fantastic information in 20 minutes

  • @JB-iz8bi
    @JB-iz8bi 4 года назад +4

    Great tutorial!

  • @alex2d324
    @alex2d324 4 года назад +4

    Wow! 2D Renderer! At last! :)))) BI-I-IG Thanks! :)

  • @vazquelol3097
    @vazquelol3097 4 года назад +4

    Amazing! Thanks

  • @jeremyb2120
    @jeremyb2120 9 месяцев назад +1

    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: ruclips.net/video/_SaBXY-Ejqo/видео.html

  • @familyfriendlycontent.jayp1944
    @familyfriendlycontent.jayp1944 3 года назад +1

    This is just what I needed, thank you!!

  • @MrHwizard
    @MrHwizard 4 года назад +8

    Ref should be "_MainTex" not "MainTex_"

  • @huynguyenphan4120
    @huynguyenphan4120 Год назад +1

    Amazing. Thanks

  • @BlueGooGames
    @BlueGooGames 4 года назад +2

    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..

  • @Only4GamersXyz
    @Only4GamersXyz 3 года назад +2

    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 года назад +1

      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 года назад +1

      @@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.
      ruclips.net/video/Mb5ifJL74pY/видео.html
      Please tell me how to fix this.
      Thanks

  • @jonas14812
    @jonas14812 2 года назад +1

    Amazing video, thank you so much!💪

  • @kalibeastok
    @kalibeastok 3 года назад +5

    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 года назад +16

      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 6 месяцев назад

      @@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

  • @rishabh999100
    @rishabh999100 4 года назад +3

    U r awesome 😀👍

  • @niagmest
    @niagmest 2 года назад +1

    Awesome video

  • @neozoid7009
    @neozoid7009 2 года назад +1

    Awesome

  • @NoeliusMax
    @NoeliusMax Год назад +2

    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  Год назад +1

      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 Год назад +2

      @@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.

  • @AdidasDoge
    @AdidasDoge 3 года назад +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

  • @Vasquez2701
    @Vasquez2701 2 года назад +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 года назад +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

  • @komamon5566
    @komamon5566 4 года назад +1

    Can you make electricity using this method?

  • @ksong5589
    @ksong5589 10 месяцев назад

    great video! But, How to make the rainbow Laser when shot, the rainbow color moving to target repeatedly?

  • @benfau9992
    @benfau9992 3 года назад +2

    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

  • @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

  • @Maddogs1
    @Maddogs1 4 месяца назад

    The position of the laser seems to only update every 0.3 seconds or so rather than every frame, any idea why?

  • @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?

  • @sreejithkakkat
    @sreejithkakkat 3 года назад +1

    Will it work on mobiles without much processing

  • @wellingtonipf
    @wellingtonipf 4 года назад +2

    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

  • @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.

  • @LePetit2
    @LePetit2 3 года назад

    I don't know how you make the laser look that blurred and brighten. I just get the texture to work.

  • @shinebatganbat4816
    @shinebatganbat4816 Год назад

    Great video mine doesn't have unlit in universal render pipeline/particles what could it be forgotten?

  • @elithevil
    @elithevil 3 года назад

    How to disable global bloom for weapon and other things except the laser line?

  • @binhlequocthanh9125
    @binhlequocthanh9125 4 года назад +1

    you're the best

  • @yuvibarbash
    @yuvibarbash 6 месяцев назад

    Great Stuff
    how do i create this as a pixel art?

  • @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?

  • @holtras8786
    @holtras8786 3 года назад

    Please tell me why my line from line renderer is completely no smooth. Its look so bad

  • @kendraw8445
    @kendraw8445 3 года назад +1

    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 года назад +1

      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.

  • @myunity8488
    @myunity8488 3 месяца назад +1

    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 3 месяца назад

      You are my new favorite person.

    • @Brecken_Nicholes
      @Brecken_Nicholes 3 месяца назад

      Do you have a method of turning off the VFX? I don't know how to lol.

    • @andytorres5721
      @andytorres5721 Месяц назад

      dawggg you saved me so much time!

  • @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

  • @techstorm.3461
    @techstorm.3461 3 года назад

    Yo, how (and could I) could I use this as some kind of attack for my platformer game?

  • @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

  • @himeyuxi7125
    @himeyuxi7125 6 месяцев назад +1

    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 6 месяцев назад

      Add Global Volume to your project. Google Unity: How To Add Bloom In URP

  • @kartheekvajrala2487
    @kartheekvajrala2487 4 года назад

    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.

  • @agustin9594
    @agustin9594 4 года назад

    In my game the laser looks horrible, where i can get a tutorial for configure universal render pipeline?

  • @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?

  • @12a2-nguyenduy8
    @12a2-nguyenduy8 4 года назад +1

    when i created Global Volume, i can find bloom to add , help :((

    • @meatyourhouseatnight
      @meatyourhouseatnight 4 года назад +2

      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 :(((

  • @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?

  • @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 года назад +1

      I figured it out. had to change the default material to Sprite Lit Default

  •  3 года назад

    Do anyone knows how to reflect the laser????

  • @prietinho6690
    @prietinho6690 4 года назад

    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

  • @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).

  • @Brecken_Nicholes
    @Brecken_Nicholes 3 месяца назад

    Does this only work in URP? I already have a non URP project created.

    • @Brecken_Nicholes
      @Brecken_Nicholes 3 месяца назад

      Oh, also I sent you an email. Would you possibly be able to respond to that?

  • @nothingatall6703
    @nothingatall6703 2 года назад

    The thickness of the laser doesnt really change its size, can u please help

    • @himeyuxi7125
      @himeyuxi7125 6 месяцев назад

      Increasing it doesn’t change much
      But decreasing the value until it gets negative thickens it

  • @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 Год назад +3

      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

  • @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?

  • @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.

  • @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.

  • @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 года назад +2

      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 года назад +6

      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.

  • @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 года назад +1

      @@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 :)

  • @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.

  • @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 3 месяца назад

      @@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.

  • @vladionete932
    @vladionete932 3 года назад

    The particles are never played out.

  • @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 2 года назад

      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 2 года назад

      @@freestylerak6655 I fixed it by lowering the bloom "clamp" value to something reasonable.

  • @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 года назад +1

      Bloom too high maybe? Dunno

    • @Lost1nTranslation
      @Lost1nTranslation 4 года назад

      @@GabrielAguiarProd I will try and lower the bloom. Maybe its a bug as well. Thank you!

  • @SierraDyne_
    @SierraDyne_ 3 года назад

    download link?

  • @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

  • @ghfgh_
    @ghfgh_ 10 месяцев назад

    want to add this but need to switch to URP ahhhhhhh

  • @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

  • @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.

  • @kaleb_t4818
    @kaleb_t4818 3 года назад

    it would be nice if u had released the project on github

  • @freestylerak6655
    @freestylerak6655 2 года назад

    why my raycasting not working

    • @GabrielAguiarProd
      @GabrielAguiarProd  2 года назад

      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 2 года назад +1

      @@GabrielAguiarProd Thankyou. I used layermask to avoid other objects then it worked.

  • @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.

  • @evanraab2104
    @evanraab2104 3 года назад

    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  3 года назад

      Use a Coroutine for example. Google it, they are quite easy to implement. Hope this helps.

    • @evanraab2104
      @evanraab2104 3 года назад

      @@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 3 года назад

      nvm, you were right, the coroutine works great! thank you!

  • @ruisenior7778
    @ruisenior7778 3 года назад

    Yeaaah

  • @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

  • @drewlevithan9411
    @drewlevithan9411 4 года назад +1

    at least tell which fricking template to open up first

    • @GabrielAguiarProd
      @GabrielAguiarProd  4 года назад

      At least don't skip the 0:40 part

    • @drewlevithan9411
      @drewlevithan9411 4 года назад

      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  4 года назад

      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 4 года назад +2

      @@GabrielAguiarProd thanks so much. Same to u and again sorry.

  • @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.

  • @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