Advanced Drag & Drop system for your Game in Unity!

Поділитися
Вставка
  • Опубліковано 26 лис 2024

КОМЕНТАРІ • 53

  • @DevLeonardo
    @DevLeonardo  2 роки тому

    Let's do some networking guys! :)
    We can get in touch on Twitter: twitter.com/Balastrong
    If you like reading articles, here's my dev.to profile: dev.to/balastrong
    If you're more on social networks: www.tiktok.com/@balastrong and instagram.com/devbalastrong/
    See you there!

  • @aliadjorlu6264
    @aliadjorlu6264 3 роки тому +1

    Thank you. Your voice and attitude is so chill - I really enjoyed this tutorial.

  • @isol8id
    @isol8id 7 місяців тому +1

    Late comment, but if it helps anyone - when setting the Dragging layer number in Layer at the very start of the video, make sure the number you set matches the layer number in the inspector! I just picked a random slot and didn't realise the number coincided with what is typed into the Layer script! DevLeo used slot 8 so in Layer script it must say slot 8 not a different slot etc.

  • @DevLeonardo
    @DevLeonardo  3 роки тому +3

    What's up, GameDevs?
    I'm sorry if it took a little bit longer than expected to publish the second part of the tutorial, but finally, here it is!
    Feel free to suggest any topic for future videos, I'd like to give priority to community request :)
    See you in the GameDev journey!

    • @augusteastburg
      @augusteastburg 3 роки тому +2

      It would be super helpful if you could publish the source code in the comments or description for newbies like me that get stuck

  • @carlescolomarcalatayud9674
    @carlescolomarcalatayud9674 3 роки тому +1

    Great Tutorial, thank you so much for sharing it with us!

    • @DevLeonardo
      @DevLeonardo  3 роки тому +1

      Hey Carles, welcome to the channel! That's great to hear you enjoyed the tutorial! Did you also watch the part one or you started from this one? :)

    • @carlescolomarcalatayud9674
      @carlescolomarcalatayud9674 3 роки тому +1

      @@DevLeonardo Yes I have seen the 1st one also. I have been looking for this system all the week and then I found you!!

    • @DevLeonardo
      @DevLeonardo  3 роки тому +1

      You're welcome :P

  • @cryo7180
    @cryo7180 3 роки тому +4

    Hey! not sure but on my side, i have a Bug where in, while collision, it doesn't update the Item to Move away from each other, it only updates when i click on another game object.

    • @marcuhlherr434
      @marcuhlherr434 3 роки тому +1

      same here!

    • @augusteastburg
      @augusteastburg 3 роки тому +1

      Same here

    • @DevLeonardo
      @DevLeonardo  3 роки тому +1

      Hey guys, thanks for letting me know! Maybe I have skipped something in the video... I'll check and get back to you soon!

    • @geeklabs.4749
      @geeklabs.4749 3 роки тому

      Same ☹️

    • @Phelaidar
      @Phelaidar 3 роки тому

      @@DevLeonardo Same here... it does check if its colliding, but its not doing anything after that

  • @waddupshairie
    @waddupshairie 2 роки тому +1

    hey i have a question on how do I want to make, for an example i want to make gem can only insert at green but not at red and the coin can insert to red but not at green ?

    • @DevLeonardo
      @DevLeonardo  2 роки тому

      Welcome to my channel and thanks for the question!
      In your OnTriggerEnter2D you have a reference to the other object you collided with. You can assign a script to the boxes with a public list of strings of items that can be inserted.
      Inside the function, you will just check if the items that you're dragging is in the allowed list :)

    • @waddupshairie
      @waddupshairie 2 роки тому

      @@DevLeonardo So what you mean is that i need to assign list of item that can be inserted in the if(other.comparetag) right ?

  • @nghtrunnr7378
    @nghtrunnr7378 2 роки тому

    Is there a way I can skip the auto reposition part? thanks.

  • @lora6938
    @lora6938 3 роки тому

    Bernardo, now I have a question about your video:
    1 what to add to the script so that the sprites are very smoothly attracted(glued). Was smooth pull (sprite gold)? And:
    2 What and where to change in the script so that the gold (sprite) can no longer be pulled out of the box. So that two sprites (gold and a box) become like a background?

  • @husniyahazman3603
    @husniyahazman3603 3 роки тому

    hello! thanks for the great video ! just wanna ask, for the image that we want to drag, is it need to choose image in UI at the hierarchy at the left side? hope you'll answer this. thanks :))

  • @julianbridges838
    @julianbridges838 Рік тому

    Great video!
    I have an issue with my sprite snapping to a z location off screen when i click down, in the inspecter its last position is z -641009.9 every time (no console errors and scripts, tags, rigidbodys, and colliders attached). Any ideas and Id be exceedingly grateful haha :)

  • @NUZASARY
    @NUZASARY Рік тому

    How... Drag & Drop way of system UI

  • @aussiedev5930
    @aussiedev5930 3 роки тому

    how do you make the sprites position stay inside the screen space of any resolution or size screen?

    • @guilhermepontarolo7095
      @guilhermepontarolo7095 2 роки тому

      you need to configure your canvas. In render mode you set "Screen space - overlay", and set the canvas scaler, in UI scale mode to "Scale with screen size".

  • @ginsengjin
    @ginsengjin 3 роки тому

    Doesn't work. The colliding of two object doesn't work at the end of the drag, it works at the start of one.

    • @soco5338
      @soco5338 2 роки тому

      He made an error in the code. Inside the Update method of DragController, he used Input.GetMouseButtonDown instead of Input.GetMouseButtonUp

  • @lora6938
    @lora6938 3 роки тому

    Hello
    How to make a sprite come to the front on mouse click? Please 🙏

    • @bernardoamim9601
      @bernardoamim9601 3 роки тому

      You can change it's sorting layer to one on top and then return it to the original

    • @lora6938
      @lora6938 3 роки тому

      @@bernardoamim9601 I understand in words
      But I don’t understand how it should look
      Can you help?
      I would like to do as in this video:
      ua-cam.com/video/h9R8M65V9H4/v-deo.html

    • @bernardoamim9601
      @bernardoamim9601 3 роки тому

      @@lora6938 Sure. The Game Object that contains the Sprite has a Sprite Renderer component in the Inspector. If you look at the bottom of the Sprite Renderer Component section, you'll see an "Additional Settings" dropdown with two fields: 'Sorting Layer and Order in Layer'. To make the dragged object go on top of everything else, you need to set it to a sorting layer with a higher order while dragging and then return it to the original sorting Layer

    • @lora6938
      @lora6938 3 роки тому

      @@bernardoamim9601 Can you help me do it as in the video. ua-cam.com/video/h9R8M65V9H4/v-deo.html
      What to write in the script and how to set it up later?

    • @bernardoamim9601
      @bernardoamim9601 3 роки тому

      ​@@lora6938 Nice! You're almost there! Only a few tips:
      - On your sorting layers, click "Add Layer". You'll have some sorting layers there. Something like "Layer 1, Layer 2".
      - Rename one of them to "Sprites" so that you know which you should work with.
      - On you Sprites, go to the Sprite Renderer at the inspector and change the Sorting Layer to be the one we just created
      - On the "Sorting Order" field, you can leave it at zero for now.
      - On your script, you are only working with the mouse down event, but what we need to do is set the sorting order to a higher number while dragging and return it back to zero at drag end.
      - So try this:
      OnMouseDown ()
      {
      gameObject.GetComponent () .sortingOrder = 10;
      }
      OnMouseUp ()
      {
      gameObject.GetComponent () .sortingOrder = 0;
      }
      If all of your sprites are default setted with "Sprites" sorting layer, and sorting order = 0, it should be working now