Use any texture and animations for Unity's Line Renderer

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

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

  • @ElPhezo
    @ElPhezo Год назад +6

    "we can't see shit" and "reduce depression" killed me, absolutely unexpected deadpan delivery. Great video.

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

    This is low-key one of the most useful unity channels 👍🏼

  • @freakymundo
    @freakymundo 2 года назад +6

    Thanks for the tutorial! I do not know if there would be any performance impact but this 4:20 can be also achieved with a Coroutine, with a yield return WaitForSeconds of 1/fps and changing the texture on each step instead of using Time.deltaTime. In this case it doesn't need to verify the fps counter every frame. Also, since the FPS of the animation is a constant value, 1f/fps doesn't need to be calculated on each frame, it can be solved in the Awake method and use a variable in the Update / Coroutine.

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

    Big like! I were looking for such this tutorial so long, You made my day. Thanks a lot

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

    Thank you for this ill keep watching you

  • @DavidBixler
    @DavidBixler 2 года назад +20

    Hey, got this working.
    For anyone who gets annoyed at stretching pixels, make sure your sprite/image "Wrap Mode" is set to "Repeat", default is "Clamp" I believe....stretchy stuff.
    Also, if anyone has a solution for using packed sprites, let me know.
    As yet, I can't find a way to read the slices in a packed sprite after slicing with the sprite editor.
    I tried using a Sprite Atlas but the Line Renderer gets the entire atlas, even if you use individual sprite frames.

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

      @@Massive-3D imagine being called a dork for trying to be helpful. Uninstalling care.exe

    • @Massive-3D
      @Massive-3D Год назад

      @@everlastingmedia Imagine thinking I give a shit. Everlasting Media but has ZERO media. Good job with all that.

    • @VenerioUvandy
      @VenerioUvandy 8 месяцев назад +1

      Thanks a lot man!

    • @janikcodes
      @janikcodes 5 месяцев назад

      godbless you.

    • @curiouspinoytv
      @curiouspinoytv 3 дня назад

      I have set the sprite/image to Wrap Mode but still I get the stretched pixel. Using unity 2022 btw.

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

    Hey Shack Just tumbled across your videos. They are great and found all the things that I want in them. Great work

  • @RamHornBeast
    @RamHornBeast 3 года назад +16

    Why can't unity themselves provide tutorials like this. Super helpful, thanks!
    Is there any way to have the texture repeat every n units, rather than per unit?

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

      Tbf there's literally infinite things Unity could make a tutorial on

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

      You can add this little code:
      // width is the width of the line
      float width = lineRenderer.startWidth;
      lineRenderer.material.mainTextureScale = new Vector2(1f / width, 1.0f);
      // 1/width is the repetition of the texture per unit (thus you can also do double
      // lines)

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

    Nice video

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

    Very helpful Sir 👍, It is also solved the problem that I was in from weeks.

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

    Thanks a lot! I'm going to use this in 3d for a jam game.

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

      Cool, can you send me a link when it's done?

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

      @@ShackMan Unfortunately ran out of time before I could implement it. Will do in the future.

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

      @@sohrabhamza3805 Running out of time is part of a game jam ;-)

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

      @@ShackMan haha true!

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

    I need help. I've been unsuccessfully trying to add a line of code that updates the firing position of this Tesla coil object when it's moving on the screen, and I want to adapt it for a moving spaceship.

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

    Helped me in my project ! Thank You

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

    When I destroy the mosnter and want to destroy the line attached to that monster. How Can i know which line should I destroy? Thanks

  • @Diamond-yn4nu
    @Diamond-yn4nu 3 года назад

    thank you please more simple tutorials like this

  • @やゆよ-d1z
    @やゆよ-d1z 3 года назад +2

    Great tutorial! Thx.
    How can I change scale of line texture?
    My texture looks too tiny on line renderer.

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

      Change the width of the line either in the inspector with the graph, or in script with lineRenderer.widthMultiplier = ...

    • @やゆよ-d1z
      @やゆよ-d1z 3 года назад

      @@_Vesper
      Thanks.
      But it looks wider.
      imgur.com/a/JYPGRzE
      I want to keep aspect ratio.
      For now, I'm dealing with this problem by making sprite bigger. (4Pixel in 1Pixel)

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

    Thanks for the guide,
    what tool did you use to create the tiled image for the lightning arc?

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

      Hi! I used Krita, it's free and is great for animation. I used the technique I explained in this video: ruclips.net/video/V7VjId-77BM/видео.html.
      So I draw a frame and make sure it wraps on both ends, then do the same for the next frame.

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

      @@ShackMan Awesome, thanks

  • @gregorymagid85
    @gregorymagid85 11 месяцев назад

    Thank you for the video, it was great,
    Question:
    I need a laser for a disco ball-type effect like in Royal Match for mobile 2d urp game , I also need a way to determine the Line Renderer color, ensuring it has different colors when a player chooses a specific color. Does anyone know or can provide a clue or link on how to achieve that?"

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

    Hey bro, why the function tile not work? just put the texture and on the final texture just strecht over the finals pixels

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

    I have this error right after finishing the Weapon script
    The type or namespace name 'Creature' could not be found (are you missing a using directive or an assembly reference?)
    I imagine I have to somehow import the Creature prefab into the script, but I don't know how. I have been following the tutorial and I don't see any difference. Please help!

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

      It means that there is no script called 'Creature'. Did you use custom namespaces and put it in another one?

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

    This has helped me a lot! Thank you so much!

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

    Is there a way I could tell the animation to stop after its played every sprite?

  • @kodaxmax
    @kodaxmax 7 месяцев назад

    following the steps up till 3 minutes, the lightning texture is stretched horizontally along the line. it repeats too, but it's still stretched, it's also really thin. this is on unity 2022 URP. Anyone know how to fix? both the texture and material previews look as expected and ive triple checked all my settings against the video.

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

    we can use multiples material in the same line, using de index lenght?

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

      You can cycle through different ones. If you want to use them in the same line at the same time, you could split the line into 2, just start the second one where the first one ends with a different material.

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

    Thank you so much bro! You saved my life

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

    Can you do a f18 fighter plane H.U.D display.where a target icon on the canvas follows tank or other fighter plane in the sky in the 3d environment?

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

    Awesome vid, helped a lot!
    Is there a way to change the tiles of the line individually, so that the line consists of different images?

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

      sorry, I don't know a way to do that, I haven't played around with it for a while. Would be pretty cool though, you could have those electric lines and send little energy balls from start to finish.

  • @678crazydave
    @678crazydave 3 года назад

    For some reason there is a huge gap between the tiles in my line :/

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

    This tutorial helped me a bunch, but I'd love to get more control over these animations. Where could I learn this? Because this isn't using Unity's standard animation tool that I keep finding tutorials on. Thank you!!!

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

    Nice video!

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

    Is there any way to add functionality like clicking on these lines? As far as I understand unity I think that requires a collider, however ,the colliders do not fit the lines.

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

      You could just use a box collider and stretch it by scaling it. If you mean clicking on these lines very precisely, close to the pixel, you would have to make a polygon collider for each sprite and loop through it just like we do with the sprites.

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

      @@ShackMan Thanks!

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

    Nice tutorial! Does anyone know the way to have the same result but with first and last sprites staying the same. I want to make a double edged arrow line so that middle part stretches but end points stay as arrows (like a dimesnsion tool).

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

      Is this for UI? In that case it would be very easy with slicing the sprite. For ingame/line renderer you could just place the ends by script and use the line renderer only for the middle part.

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

      @@ShackMan Not not for UI. It's ingame object. I managed to do it in a different way. I created double arrow sprite and made border so that only middle part extends. And instead of line renderer I used regular sprite renderer and use it's size.x value. You just have to position sprite renderer gameobject in the middle and increase size.x which autotiles from the middle and creates custom length arrow.

  • @cometgamerid
    @cometgamerid 7 месяцев назад

    Big like bro big like ❤🥰

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

    This error appears, please help me \Bio-TecN\SCRIPT\Weapon.cs(26,24): error CS0029: Cannot implicitly convert type 'Creature[]' to 'System.Collections.Generic.List'
    allCreatures = Resources.FindObjectsOfTypeAll();

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

      FindObjectsOfType returns an array, allCreatures seems to be a list. Simply add 'ToList() right before the semicolon.

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

      like this? allCreatures = Resources.FindObjectsOfTypeAll()ToList();
      Errors continue to appear on this line, an error also appears when I change from ''Count'' to ''Length'' on another line as shown in the video at 13:59.
      for (int i = 0; i < allCreatures.Count; i++)

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

      @@CortesVidaSaudavel645 You forgot a . between () and ToList().
      Count and Length is because of array vs list. Google a bit about the differences, there are many articles about it.

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

      @@ShackMan I saw now that later on you eliminated this first line and kept ''Count'' in the other.
      I put a 2d collider and a Tag in ''Line Renderer'' so that the player who touches any point in the radius will be destroyed, but it's not working. How could I do it? Because I adapted this example to a kind of barrier in a ''Shoot in Up'' style ship game where two ships create this plasma arc to destroy the player if he touches anywhere on the line.

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

    Thanks man !

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

    YOU SAVE ME Thank a lot!

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

    Awersome, thanks

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

    how can i get cursive writing or caliigraphic writing effect please help?

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

      Can you explain in more detail? Not sure what you mean exactly. Greetings

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

      @@ShackMan
      Thank you so much for your reply,
      I want to make a writing type game , In which player move the finger on the screen in the shapes of alphabet obviously, and the shapes are made ,
      Till now I used line renderer on mouse position...but there's one main problem in this approach that is the line looks normal drawing, and I want to give cursive writing feel to the player.

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

      If I understand correctly, you would simply have to use a lot of points in the line renderer, so it appears to a be a round line even though it's just a lot of small straight lines.
      If you want the user to draw a letter by hand and your game recognizes which letter that was, that would be a lot more complicated.

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

      @@ShackMan
      Yeah , I tried width curve and line points , different points break but nothing looking good,
      Btw thank you so much you look into this, I will try something ....

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

    What if I want to change more than 60 textures in 1 second? The update is being called only 60 times.

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

      No, update is called as often as possible. Unity calls every script that has an Update method, and when everything that was effected by those methods finishes, a frame is put on the screen. Then the loop runs again. Try to research a bit more into it. It can be confusing at first (it was for me), but once you understand the concept of update loops in Unity, it is very useful.

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

      @@ShackMan The thing is, I'm using a nodecanvas system where the OnUpdate method is called every frame. But when I put a debug in there, I only got 60 debugs back. The exit condition was :
      protected override void OnUpdate()
      {
      Debug.LogError("updateCall");
      if (remainingTime

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

      @@ShackMan Ok I've solved it by removing from deltatime and checking with
      if (remainingTime 2/100 ...
      I found out that the OnUpdate method was only called when the child nodes were updated. I wonder if there is a better way of doing this thing in general. Like not changing the material texture.

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

    awesome tutorial! what if you wanted to destroy the linePrefabs and just spawn new ones each time you press the button?

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

      You'd just move the line where the line renderer is instantiated in the Update method where we check for input. And also keep a reference to it with a field (for example activeLine), so when another key is pressed we can call Destroy and pass in the activeLine.gameObject). One problem here is thought that if you create more than one, you only have a reference to the last one created and can only destroy that. Depending on what you are trying to achieve, this might be enough though.
      private LineController activeLine;
      private void Update()
      {
      if (Input.GetKeyDown(KeyCode.Space))
      activeLine = Instantiate(linePrefab);
      if (Input.GetKeyDown(KeyCode.Enter))
      Destroy(activeLine.gameObject);
      }

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

      @@ShackMan that worked! thank you. I wanted my Player who was mobile to be able to do this, but to different objects that would connect to each other (using the line). This is a great starting off point - can't wait to learn more from your channel

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

    what I understand is that you just change the texture of line continuously. Can we assign animation to the line renderer?

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

      You mean using an animation clip, right? I haven't tried it out, since this is exactly what animation (2D) does, it just swaps the sprites. But of course it is much easier to edit animations and add stuff like rotation.

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

      @@ShackMan yeah because I want to make it look like particles. I dont know changing length of the particle is possible.

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

    Thank you!

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

    ehh why tiling not work?

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

      recheck your Wrap Mode 0:50

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

    god

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

    For the trick @2:40 What the heck Unity!

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

    "As you can see, we can't see shit" LOL

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

    3 years of unity and never used the lock inspector icon. lol wow

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

    "We can't see shit"😂