ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

Unity Tutorial - Drag & Drop Tutorial #1 [RPGs, Card Games, uGUI]

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ส.ค. 2024
  • Make sure to SUBSCRIBE so you don't miss a video!
    Download the complete project: quill18.com/uni...
    Also, please feel free to ask lots of questions in the comments.
    This channel is mostly all about game programming tutorials, specifically with Unity 3d. You may also be interested in my primary channel, where I play and review games: / quill18
    I can be reached at:
    quill18@quill18.com
    / quill18
    / quill18

ความคิดเห็น • 252

  • @augusthippo146
    @augusthippo146 9 ปีที่แล้ว +53

    I actually really appreciate that these videos have you miss stuff, "screw up", et cetera. I actually learn just as much about your method of solving stuff as the actual content: REALLY USEFUL.
    Great videos, I just finished the second. Thanks!

  • @robtvogel
    @robtvogel 9 ปีที่แล้ว +9

    I enjoy how real you are, not snipping when you mess up. These are things that happen when coding and working through them is a valuable lesson. I really liked that all 3 steps were published on the same day, even though I didn't find them til now.

  • @quill18
    @quill18 9 ปีที่แล้ว +63

    All three parts will be live today.

    • @johnnyxp64
      @johnnyxp64 9 ปีที่แล้ว +3

      you are amazing. i liked that you demo had card reordering when even blizzard's heart stone doesnt and it was created with unity as you may know.

    • @Snipppss
      @Snipppss 9 ปีที่แล้ว +3

      ***** That's a design choice, though. Not reordering hand in HS allows people to see when you drew a card, which is important at high levels :)

    • @nicoskyline6054
      @nicoskyline6054 5 ปีที่แล้ว

      I have a project for you quill it's a easy one if you want...let me know if you are up for it thanks 😁😁😁

  • @kevnar
    @kevnar 9 ปีที่แล้ว +178

    Sounds like you're saying "Dragon Drop". Sounds like some kind of wrestling move.

    • @tranquilmagister8481
      @tranquilmagister8481 7 ปีที่แล้ว +8

      ty, i always have a hard time coming up with a name for my games; "dragon drop" will do xD

    • @farmersparadise7977
      @farmersparadise7977 6 ปีที่แล้ว +1

      dragon smackdown lol

    • @80amnesia
      @80amnesia 5 ปีที่แล้ว

      Great "Dragon Drop" tutorial

    • @tranquilmagister8481
      @tranquilmagister8481 5 ปีที่แล้ว

      @Luka Grouwstra everyone needs a hobby xD

    • @brandonponce2159
      @brandonponce2159 3 ปีที่แล้ว

      Once you read this there's no different way to hear it

  • @Aeroxima
    @Aeroxima 8 ปีที่แล้ว

    I love how you show the process and how you come to answers and deal with issues that come up (or would come up in theory). The official Unity tutorials seem to often just say "1. do this. 2. do that. 3. enter this 4. done" and you end up not really learning much.

  • @SaSeshen
    @SaSeshen 3 ปีที่แล้ว

    dude, to be perfectly honest I am glad that you didn't edit out the mistakes. Learning and following these kinds of tutorials is one thing, but seeing troubleshooting in action and then understanding why the problem occured in the first place is significantly more valuable than being given a step by step instructional on how to do something! Thank you so much!

  • @Tocoquinh0
    @Tocoquinh0 5 ปีที่แล้ว +5

    Quill, thank you very very very much.
    I was just about to give up on doing my card game, because i couldn't find anything that was really useful and i was veeeery lost, so i started to lose motivation. But now i found this video and i am finally starting to understand a lot of things and i am as motivated as ever again. So thanks a lot =D

    • @rogersf2317
      @rogersf2317 5 ปีที่แล้ว +1

      Situations are exactly the same for me, dude! Lets keep it up

  • @Schebberroch
    @Schebberroch 9 ปีที่แล้ว +3

    OMG. I have been looking for a tutorial covering something like the Hearthstone interface for a long time now. It really pays off to be subscribed to your channel, Quill.

  • @jasonboss8793
    @jasonboss8793 8 หลายเดือนก่อน

    I just realized this video is 8 years old. I can't believe it, most videos from only 5 years ago have quality worse that an ebay product. This being 8 years old with such good quality is amazing to me

  • @jessierose13
    @jessierose13 7 ปีที่แล้ว

    Thanks for not locking your tutorials behind a pay wall. Seriously, it saves me a lot of stress trying to make a complex TCG simulator.

  • @wynrush3735
    @wynrush3735 6 ปีที่แล้ว +3

    Hey! Just wanted to say thanks for this! Excellent, clear instructions. Your approach to teaching is really natural - warm, exploration oriented, curious - and it's helped me feel welcomed to the Unity dev community (this is my first solo dev project). Thankstytytyty

  • @TooScoops18
    @TooScoops18 9 ปีที่แล้ว

    Thanks for this tutorial, you explained it so I could finally understand. I viewed another similar tutorial that did not explain the reason for everything, but in that tutorial, I did learn that you can right-click on "IBeginDragHandler" and choose "Refractor" > "implement interface", and it will create the function for you, which you can position in your code anywhere by pressing the up and down arrows.

  • @hantaakai8183
    @hantaakai8183 9 หลายเดือนก่อน

    It is insanely valuable to see problems appear in the middle of work and the process of solving those! Thanks a lot :)

  • @that1dude66
    @that1dude66 7 ปีที่แล้ว +1

    Great job with this tutorial! I usually can't stand when people present tutorials and they run into issues like you did. However, I appreciate when coding tutorials do because there's so many errors you can run into without realizing what the heck is going on. Great enthusiasm, great explanation, great tutorial overall.
    Liked and subscribed!

  • @pyth0nic
    @pyth0nic 9 ปีที่แล้ว +3

    Perfect timing! I've been trying to figure this stuff out for a couple of weeks. Thanks.

  • @GamePilLP
    @GamePilLP 4 ปีที่แล้ว

    I havent watched the 2nd part yet so i don't know what you are proposing yet but the way i would do it is to make the Drag Start function save the original location and make the Drag End function check if it is colliding with a slot it can go into and then if it does set it to the slots position and if it doesnt set it back to the original location

  • @johaneriksson433
    @johaneriksson433 9 ปีที่แล้ว

    I gotta say I love your 'on the fly trouble shooting', makes one less spoiled when it comes to handling errors :) ty!

  • @Sammyson101
    @Sammyson101 7 ปีที่แล้ว

    I've been subscribed to your gaming channel for some time now, glad to finally find out that you have been doing coding tutorials as well.

  • @Turtwiggyyy
    @Turtwiggyyy 6 ปีที่แล้ว +2

    if anyone's still using this & needs the simple solution to add the offset mentioned at @23:43:
    public class Draggable : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
    {
    Vector2 offset;
    public void OnBeginDrag(PointerEventData eventData)
    {
    Debug.Log("OnBeginDrag");
    offset = transform.position - new Vector3(eventData.position.x, eventData.position.y, 0);
    }
    public void OnDrag(PointerEventData eventData)
    {
    Debug.Log("OnDrag");
    transform.position = eventData.position + offset;
    }
    public void OnEndDrag(PointerEventData eventData)
    {
    Debug.Log("OnEndDrag");
    }
    }

    • @jonathanwitting3519
      @jonathanwitting3519 3 ปีที่แล้ว

      Thanks man! I couldnt figure out how to fix the offset

  • @EJdoomsday
    @EJdoomsday 9 ปีที่แล้ว

    I've been looking all over for a tutorial about this, you're a life saver Quill

  • @nuclearwolves4455
    @nuclearwolves4455 6 ปีที่แล้ว +2

    If anyone wants to know how to make it draggable from any position, just do something like:
    Vector2 dragOffset = new Vector2();
    public void OnBeginDrag(PointerEventData eventData)
    {
    dragOffset = (new Vector2(this.transform.position.x, this.transform.position.y) - eventData.position);
    }
    public void OnDrag(PointerEventData eventData)
    {
    this.transform.position = (eventData.position + dragOffset);
    }

  • @antonionatilla9848
    @antonionatilla9848 6 ปีที่แล้ว

    Sincerely liked this. You're awesome at explaining, and, for the first time, I'm so sorry I can't donate to someone as talented as you. Also, so "human-ish" to be "improvising", trying to rebuild all of the system on the fly, showing not only ways to do things, but also ways to solve problems and how to look at them to understand where the problem is!

  • @TheMadHermit
    @TheMadHermit 5 ปีที่แล้ว

    Fantastic video. Love the pace and level of detail you go into. Liked and subscribed!

  • @Sam-xm8nr
    @Sam-xm8nr 9 ปีที่แล้ว

    Extremely helpful, nice slow approach which is great since you actually explain what things are doing, so that when i use these idea's i know WHY I'm using them, rather than just copying blindly. Thanks :)

  • @MegaArcon
    @MegaArcon 9 ปีที่แล้ว

    Simple, informative, and useful tutorial. You're an engaging presenter. Thanks for creating, I really appreciate your time.

  • @IanEdmonds
    @IanEdmonds 8 ปีที่แล้ว +4

    "Why am I doing this? Because I have to."
    I know that feeling!

  • @Thatonefuckinguy
    @Thatonefuckinguy 9 ปีที่แล้ว

    I love these videos this is such a relief from most tutorials where I'm like yep this is rocket science. this is much easier to understand.

  • @kevmscotland
    @kevmscotland 9 ปีที่แล้ว +5

    Great video. Glad to see the channel active again. Out of curiosity, where did you get the sample projects?

    • @quill18
      @quill18 9 ปีที่แล้ว

      ***** All the official Unity sample projects are on the asset store now. (The are free.)

  • @tomoyaokazaki2138
    @tomoyaokazaki2138 3 ปีที่แล้ว

    i'm hoping these videos will help me create the card game i want to make. I'm going for something similar to Yu-Gi-Oh and Pokemon tcg but in what looks like a battlefield kind of layout. So I hope your videos will also provide how the npc functions. I want to make a card game that can be PvP, PvE, and co-op. PvE referring to you vs. an npc instead of an actual player.
    btw, thank you for the video! I recently learned JavaScript so this C# coding you made actually makes sense to me based on what everything is meant to do in your script! My only challenge now will be making the digital art for the pics of the cards as well as the backgrounds.

  • @andrewflowers4254
    @andrewflowers4254 ปีที่แล้ว

    Thanks for these videos. They still work. This is going to help me make my card game. Again Thank you.

  • @TheKarishi
    @TheKarishi 8 ปีที่แล้ว

    FYI, a perfect card aspect ratio would be 100x140. Poker cards (and, consequently, Magic cards) are exactly 2.5 by 3.5 inches.

  • @fragostafylo
    @fragostafylo 9 ปีที่แล้ว

    We really appreciate your effort Quill. Thanks for the tutorials

  • @terrythomas9587
    @terrythomas9587 4 ปีที่แล้ว

    Nice tutorial. Just something to keep in mind, layouts (Grid, horizontal, vertical) want to keep a certain vertical or horizontal pixel count which tends not to work well when changing screen resolutions.

  • @PoprawnyPolakHD
    @PoprawnyPolakHD 9 ปีที่แล้ว +1

    Wow, wow, wow I really need to get better at UI and this appears! I'm hyped.

  • @OniricChef
    @OniricChef 9 ปีที่แล้ว +5

    Thanks Quill, thank you so much for doing this, especially in C# and not JS!

  • @vertexcrusher
    @vertexcrusher 6 ปีที่แล้ว

    Thanks a bunch, this is an excellent tutorial, you don't waste any time, everything is useful and you know how to say things in order for me to understand.

  • @user-jr7nd4xj2g
    @user-jr7nd4xj2g 9 ปีที่แล้ว

    All of your tutorials are so much awesome

  • @JokerKizer
    @JokerKizer 2 ปีที่แล้ว

    Thanks for keeping this video up. I recently purchased the CCG Kit asset for unity, but the documentation only covers how to use their prefabs / assets.

  • @Sumdottycoy
    @Sumdottycoy 8 ปีที่แล้ว

    Super quick n helpful. Could you explain a bit more thoroughly how to keep the mouse icon static opposed to it moving to the middle of the object we're trying to drag?

  • @arabianchessfriends
    @arabianchessfriends 7 ปีที่แล้ว

    does the object have to be a UI? it doesn't seem to work for me with normal objects..the drag handler is not doing anything
    here's the code in case it doesn't have to be a UI:
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.EventSystems;
    public class draggable : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler {
    public void OnBeginDrag (PointerEventData d) {
    }
    public void OnDrag (PointerEventData data) {
    Debug.Log ("working");
    this.transform.position = data.position;
    }
    public void OnEndDrag (PointerEventData d) {
    }
    }

  • @AlionaMatveeva
    @AlionaMatveeva 4 ปีที่แล้ว +1

    somehow, the sprite i'm trying to drag disappears and never comes back after I trigger OnDrag. did it happen to anyone else? can't fix it, googling didn't help. I tried rearranging objects in canvas so that my bg image is upper in hierarchy than the sprite i'm intending to move, but it disappears anyway :( please help

    • @sonsenvrac945
      @sonsenvrac945 4 ปีที่แล้ว

      Hi Aliona, hope you did found a solution but if you don't consider than it's an old tutorial so i guess it's not really useful anymore. Anyway, having the same problem i end on following this tutorial th-cam.com/video/BGr-7GZJNXg/w-d-xo.html , so far it looks more suitable, good luck!

  • @staind2523
    @staind2523 9 ปีที่แล้ว

    Very cool! Glad to see some tutorials involving the new UI system. Do you plan on doing more with the Multiplayer FPS tutorial too? You gave us a great start but I'd also really like to see the next few steps. Thanks!!

  • @ThunderDraws
    @ThunderDraws 9 ปีที่แล้ว +2

    woot! unity 5! :)
    thanks for the tutorial!
    unity can be confusing at times haha, the thing with "IDragHandler" xD

  • @GamingTeaParty
    @GamingTeaParty 6 ปีที่แล้ว

    I love your OCD. "I must make sure there is NO overlap!!!"

  • @brandonsemerau5894
    @brandonsemerau5894 2 ปีที่แล้ว

    This is still great today. Thanks!

  • @justinwhite2725
    @justinwhite2725 7 ปีที่แล้ว

    OMG - I had no idea you can hold alt or shift to change the auto-anchors! There are a few things I've been upset don't exist and I've had to do manually, but they do exist and are just 'hidden'.

  • @Eragoth186
    @Eragoth186 9 ปีที่แล้ว

    Thank you so much for doing these tutorials, they really help me a lot! :)

  • @user-jq3um6ez2h
    @user-jq3um6ez2h 7 ปีที่แล้ว +1

    I just pause at the wrong point and try and try and try........

  • @schizoscope8703
    @schizoscope8703 3 ปีที่แล้ว +1

    Thanks very much, even six years still usefull!

  • @KakuzuAkatsuki1234
    @KakuzuAkatsuki1234 9 ปีที่แล้ว

    Yay ! I recently asked for a new tutorial and THERE IT IS !

  • @XxjazzperxX
    @XxjazzperxX 9 ปีที่แล้ว +1

    Can't I use these: IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerEnterHandler, IPointerExitHandler, when using World Space? Because I seem to have problems with IPointerEnterHandler, IPointerExitHandler now that I changed to world space. I changed to world space because i need 2 cameras in two different locations of the same canvas...

  • @SubjektDelta
    @SubjektDelta 9 ปีที่แล้ว

    Please continue the FPS series!
    Love you Quill!

  • @prakashyadav1216
    @prakashyadav1216 8 ปีที่แล้ว

    Thanks a lot . I was searching that Tutorial from great time . You solved my Biggest Problem .

  • @MelonLordMagzy
    @MelonLordMagzy 7 ปีที่แล้ว

    just looked through your channel and it seems to have many tutorials i'll need, i might be drunk as all fuck but you just earned yourself a new sub ;)

  • @xjimdim
    @xjimdim 9 ปีที่แล้ว

    at last the king is back

  • @Risk1channel
    @Risk1channel 7 ปีที่แล้ว

    Duuude.. Finally i know how unity works... Thanks sooo much 🙏

  • @Peteslair13
    @Peteslair13 9 ปีที่แล้ว

    Thanks for doing these, i am planning a side project and this will come in handy! :)

  • @ThatPianoNoob
    @ThatPianoNoob 2 ปีที่แล้ว

    I dunno sounds to me like you should just be able to modify drag and drop behavior through object properties. Still dont get why it wouldnt be a built-in solution that just has a setting for each of the common use-cases..

  • @axiras
    @axiras 8 ปีที่แล้ว +2

    This video is such a drag...badum diss. Nice video quill, helped me alot :)

  • @danielDUCTEIL
    @danielDUCTEIL 9 ปีที่แล้ว

    You make my day, I kept on doing it wrong. I was using Button + Mouse event !
    Thank you :p

  • @kurtis70345
    @kurtis70345 8 ปีที่แล้ว +5

    Could you tell me how to drag a card on the top corner more specifically? I still cannot understand after you quickly describe the solution at 23:33.
    Thanks!

    • @prettychill8868
      @prettychill8868 5 ปีที่แล้ว +1

      Incase anyone comes across this:
      When you begin the drag you find the difference between the center of the object and the mouse and store that difference in a variable, then when it comes to the OnDrag function you have the object position equal the mouse position + the offset

    • @Errox358
      @Errox358 4 ปีที่แล้ว +2

      public class Draggable : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
      {
      float xOffset = 0f;
      float yOffset = 0f;
      public void OnBeginDrag(PointerEventData eventData)
      {
      xOffset = this.transform.position.x - eventData.position.x;
      yOffset = this.transform.position.y - eventData.position.y;
      }
      public void OnDrag(PointerEventData eventData)
      {
      this.transform.position = new Vector3(eventData.position.x + xOffset, eventData.position.y + yOffset, 0);
      }
      }

  • @NeuraPsycotica
    @NeuraPsycotica 8 ปีที่แล้ว

    Thanks so much for the tutorial, it has been very useful for my project!

  • @MrFreddieNietzsche
    @MrFreddieNietzsche 9 ปีที่แล้ว

    You are god. I'm working on a microbiology project and this is perfect!

  • @MindGem
    @MindGem 3 ปีที่แล้ว

    Question: This works fine for UI images and such. but it doesn't work on prefab gameobjects for some reason, is there anything else I need to do for that?

  • @Dabayare
    @Dabayare 5 ปีที่แล้ว

    We use to do it with just one image and a list of polygon points for each "hot area" before things got complicated building solutions that fit many different platforms and more sexy graphics.

  • @MrPupsi
    @MrPupsi 6 ปีที่แล้ว +1

    I followed everything in this Video to see if this will still work, but for some reason, as soon as i drag something around it dissapears into nowhere :D In the inspector the positions goes nuts, crazy. Maybe if someone read this, maybe even you quill, i would be happy to understand whats happening ^^

  • @TheTotococo123
    @TheTotococo123 7 ปีที่แล้ว

    Thanks for these wonderful tutorials!

  • @dietrih
    @dietrih 8 ปีที่แล้ว

    How can I programmatically move a card from one panel to another? and
    whether it is possible to set variables on the cards? Thanks!
    I use the card as the men in the game.There are 2 windows, the staff and the job is moved from the map window in personnel assignment window, time passes and I need to automatically after a job transfer card back to staff.
    Thank you very much!

  • @tobiasb.7516
    @tobiasb.7516 3 ปีที่แล้ว

    hi there! i try to drag the card from the canvas "hand" to an cube // i want to make an table with many drag fields. but i hang a little bit :( hope any one have a tip

  • @DigitalRoots
    @DigitalRoots 8 ปีที่แล้ว +1

    If anyone is curious about how to create a "smooth" drag instead of one locked to the anchors, this is the solution I implemented to achieve that effect.
    Vector2 mousePosition;
    public Vector2 difference;
    Vector2 currentPosition;
    public float smooth;
    void Start() {
    smooth = Time.deltaTime * 420;
    }
    public void OnBeginDrag(PointerEventData eventData) {
    Debug.Log("OnBeginDrag");
    currentPosition = this.transform.position;
    mousePosition = eventData.position;
    difference = mousePosition - currentPosition;
    }
    public void OnDrag(PointerEventData eventData) {
    position = GetComponent().anchoredPosition;
    this.transform.position = eventData.position - difference;
    }

    • @harisspan2725
      @harisspan2725 6 ปีที่แล้ว

      What do you mean a "smooth" drag?

  • @SahkanISR
    @SahkanISR 8 ปีที่แล้ว +3

    This guy is on "Drags" :P
    j/k thanks for the great tutorial :)

    • @amrojjeh
      @amrojjeh 8 ปีที่แล้ว

      +SahkanISR I bet he also sits in the cool lunch table with the other cool kids

  • @georgesg1683
    @georgesg1683 5 ปีที่แล้ว +1

    Can unity be used on Mac? I wanna make my own card game, but I don't know what to use or if it ca be used on my Mac computer. Little help would be amazing. Thank you.

  • @JamesMarks
    @JamesMarks 9 ปีที่แล้ว

    Imbiggen (Embiggen?) has been added to my list of favorite made up words.

  • @TheLespauljunior
    @TheLespauljunior 2 ปีที่แล้ว

    Is there any way to drag just a floating copy of the card, and not the actual image?

  • @stevenb4956
    @stevenb4956 9 ปีที่แล้ว

    Very nice. Simple and effective. Thanks.

  • @melissagilbert6913
    @melissagilbert6913 8 ปีที่แล้ว

    If you want it to do something when it is in a certain slot. Get the slot and check for the right child then do something. Hope this helps.
    [Header("slots")]
    [SerializeField]
    GameObject godOfLove;
    [Header("weapons")]
    [SerializeField]
    GameObject Heart;
    void Update () {
    if (godOfLove.transform.FindChild ("heart")) {
    Heart.SetActive (true);
    } else {
    Heart.SetActive (false);
    }

  • @excellNexcel
    @excellNexcel 7 ปีที่แล้ว

    Excellent stuff. it works well. Question: do you know how I can access the position of each hand. I am creating a scramble-word-sentence and the user must drag and drop the words in the right order.

  • @mykodagames
    @mykodagames 6 ปีที่แล้ว

    This is perfect just what Im looking for ;) will this work on mobile devices as is (without the need to change the code)?

  • @RavenFelman
    @RavenFelman 5 ปีที่แล้ว

    There is a way to make the object be always in the exact mouse point instead of "following" that point when you move the mouse around like in the video?

  • @KarthiKeyan-dx1vf
    @KarthiKeyan-dx1vf 6 ปีที่แล้ว

    Nice one ... Superb For Beginners and easy understandable...

  • @dejackle1251
    @dejackle1251 6 ปีที่แล้ว

    Ok there seems to be a bug with my program. I have no clue ,but it does the dragging thing ,but It drops my feel like (-4,-4) is distance from the card.( way lower left). I probably should try a different way or something like that. I am using the personal version and it's up to date.

  • @AyyyyyyyyyLmao
    @AyyyyyyyyyLmao 4 ปีที่แล้ว

    PLEASE can you remake this tutorial with a grid system? As opposed to making a separate canvas for each of my grid tiles.
    And if you manage it so items bigger than 1 tile could be dropped onto the grid (like a city builder) that would make all my dreams come true.

  • @dietrih
    @dietrih 8 ปีที่แล้ว

    Hi,
    How can I programmatically move a card from one panel to another? and whether it is possible to set variables on the cards? Thanks!

  • @Mythricia1988
    @Mythricia1988 8 ปีที่แล้ว +38

    Hah, how suitable to use Hearthstone as an example. That game is actually built on Unity.

  • @JhonAsleyMarcelo
    @JhonAsleyMarcelo 5 ปีที่แล้ว

    Any idea of assembly simulation where you drag objects where they should be placed properly. somehow like pc assemble simulations.

  • @willlacey7621
    @willlacey7621 4 ปีที่แล้ว

    Thanks! This was very helpful!

  • @PoprawnyPolakHD
    @PoprawnyPolakHD 9 ปีที่แล้ว

    When I basically did what you did in this episode and started dragging stuff around, my FPS went from 2500 or so, all the way to 25-50. Does this only happen to me? Should I ignore it?

  • @kordou
    @kordou 3 ปีที่แล้ว

    Greate video. Keep making these small errors :p they are quite educational

  • @josephmarsh5031
    @josephmarsh5031 7 ปีที่แล้ว

    Love your stuff bro! Subbed!

  • @burpsensei
    @burpsensei 5 ปีที่แล้ว

    Can I use it to drag and drop an object in android application?

  • @acherowyo7555
    @acherowyo7555 6 ปีที่แล้ว

    can you use this on objects that are not in the UI? If not, how would you drag something from the UI and drop it in the world space?

  • @Haooryu
    @Haooryu 8 ปีที่แล้ว +3

    i wish there was a tutorial that shows you how to make a deck and make deck shuffle, draw random cards

    • @Haooryu
      @Haooryu 8 ปีที่แล้ว

      xD

    • @jeroenvanwees3250
      @jeroenvanwees3250 8 ปีที่แล้ว +2

      +Aire
      +Serenne
      I can't help you guys with how to make a deck, but i can help with some pseudo-code for a shuffle-algorithm i once made:
      /// some dataclass representing the cards:
      public class Card{
      //data: name, values, and that sort of things
      }
      /// a simple function to shuffle an array of cards! (I believe it also works for lists, with a little adjustment ;-) )
      public Card[ ] shuffle( Card[ ] deck) {
      int length = deck.length; //how many cards are there?
      for(int i=0; i < length-2; i++){
      //switch the i-th card of the deck, with a randomly chosen card, one later down the line, (or the i-th
      // one itself.
      //This way: the first card in the deck wil be chosen randomly from all the cards,
      // the second one from al the remaining cards, etcetera
      deck = Switch( deck, i, Random.Range(i, length-1) );
      }
      //you can skip i = length-1, because at this point there is only one card left to pick: the last one, to be
      //placed at the last spot... but it's already there so it's a small step you can skip.
      //Note: some cards, especially near the top of the deck (the start of the array) might shuffle places several times,
      //but that's oke. Exept for the final placement, a card is always moving towards the back of the array, during
      // shuffling. And because the deck is finite, this process will end. (So... this algorithm won't work on an infinitly
      // large carddeck, but... i'm not really sure that wil ever really be a problem worth considering. :P )
      return deck;
      }
      // a function to switch around two cards from the deck.
      public Card[ ] Switch(Card [ ] deck, int i, int j){
      Card c = deck[ i ];
      deck[ i ] = deck[ j ];
      deck[ j ] = c;
      return deck;
      }
      //// I hope this helped you guys!
      //// Cheers, and good luck! :D

    • @blankxx0009
      @blankxx0009 7 ปีที่แล้ว +1

      Check out Sloan Kelly. He does a full tutorial on making a blackjack game with the shuffle and draw mechanic.

  • @atomic2653
    @atomic2653 6 ปีที่แล้ว

    This video was very helpful. Thank you.

  • @mr.m2193
    @mr.m2193 7 ปีที่แล้ว +1

    will this work if i use android platform?(Will the DragEvent respond to touch)

  • @robinmattheussen2395
    @robinmattheussen2395 9 ปีที่แล้ว

    Really confused as to how they implemented this. Why would they implement an interface for each event, as opposed to giving you the ability to just register / unregister event handlers (like we're used to doing on regular C# programs)? They should have put all events on a single IDraggable.

  • @Christopher-lb6rf
    @Christopher-lb6rf 9 ปีที่แล้ว

    This is a fantastic explanation. Thanks!

  • @hugomaldonado5187
    @hugomaldonado5187 8 ปีที่แล้ว

    Hi, I´m totally new at Unity, my project consists in create a kind of app similar to Packet Tracer, I´ve done the drag & drop of the routers & switches, but I have no idea about how connect these devices with a cable, as I said, it should be similar to Packet Tracer, do you have an idea for this? Or do you know? I would thank you a lot. Thanks and greetings!

  • @legromorph2854
    @legromorph2854 5 ปีที่แล้ว +2

    Sad doesnt work in 2019 (Unity 2018.3.11f1):(
    I tryed to implement it on my Card Game but it just do nothing.
    Than I downloaded your Project, but same problem.

    • @kak14100000
      @kak14100000 5 ปีที่แล้ว +1

      in case you (or someone else) are still having this problem, make sure there's a raycast target somewhere on the card then it'll work

    • @JeIIyf1sh
      @JeIIyf1sh 4 ปีที่แล้ว

      If anyone else is having this sort of issue this thread helped me alot forum.unity.com/threads/implement-a-drag-and-drop-script-with-c.130515/

  • @JurassicRampage
    @JurassicRampage 9 ปีที่แล้ว

    Hey what about making a system like a Minecraft Creative mode were you can pick a Model and can place it were you click maybe with raycast?

    • @RaidenFreeman
      @RaidenFreeman 9 ปีที่แล้ว +1

      That's not drag n drop, and easily implementable. You need a collider on the object, and a raycast on your mouse position. If it hits the collider, check the player's distance from the object, and if it's "close", deactivate it, and add it to your inventory.

  • @O113Owl
    @O113Owl 8 ปีที่แล้ว

    I get the wierdest results when doing this in 2d, the card jumps to something like x=2500, y=4000 and z = -5330, is this a feature or a bug?