Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Weird behaviour with draggable UI Image

Discussion in '2D' started by DaG_II, Apr 18, 2017.

  1. DaG_II

    DaG_II

    Joined:
    Apr 28, 2014
    Posts:
    9
    I'm making a classic card game by Unity. I created a first deck and when I click on the top card it is discarded and it moves to another second card stack. When the first card stack is empty then it is refilled when it is clicked. Furthermore I should to be allowed to drag and drop the cards in the second deck. My problem is that I can't drag and drop a card from second deck until the first deck was refilled a first time and I don't understand why. This a simple example project with a one card stack: https://mega.nz/#!r0IWWYwa!NDgO11BO8UzeZuSsVP2v6OBKlU25RLOf6pk1nFf2tJ0

    I hope somebody could help me, because I really don't understand this very weird behaviour.
     
  2. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Please post your (relevant) code here, using proper code tags and I'm sure people will be happy to help you out :)
    (I'd be back to read it, for example:))
     
    DaG_II likes this.
  3. DaG_II

    DaG_II

    Joined:
    Apr 28, 2014
    Posts:
    9
    I solved the problem. I flip a card by a rotation quaternion, so the normal of the card will be in opposite position of the casted ray when I click. Since this a 2D project, I decided to simulate the card rotation by scale vector (by uniform scale on x component).
     
  4. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    Cool. I've used that before to flip cards, too :) Glad ya got it solved.