Skip to main content

Search

I need help with logic for a card drawing mechanic like UNO or solitair

  • Supposer

    It will likely be very difficult to get the physics of an actual stack of cards to work how you would like--not to mention the performance overhead of a ton of physics happening. So you'd probably want to animate the cards instead, and activate the animation when you want them to draw a card. Have a look at the animation tutorials and see how you get on with that.

    As for applying the outcome, it all depends on the game being played and what that outcome needs to be. So you'd just have to figure that stuff out yourself, I think--unless there are more specific questions you could post here later on.

    But the first step to applying the right outcome is to identify the card in the first place. For that, the easiest way is to add tags to the card that signify different things by different names. So, if you're interested in if it's a Heart, add a tag with the name "Heart" to the right cards. If you're also interested in it's number, add a tag with the right number as its name. Then you can use a trigger zone to detect if a particular tag is on the card that was played, and trigger off logic from that. https://www.youtube.com/watch?v=RiDPatqMkJs&feature=youtu.be&t=12

  • linker12795

    I'm actually working on implementing a standard deck of cards, and finished the logic to generate a random number and interpret that as a specific card, I can upload that in a few hours.
    My solution is to generate a random number using a signal generator, use math to turn that number into a card (4 Suits, 13 Ranks). Then, I check if that card has already been generated. If it hasn't, I output that card. Otherwise I generate another number.

    But this is a pretty open ended design question and my solution isn't the only one. You could also simulate a stack (the data structure kind) of all the cards, assign them a random order, and pop through that stack in order.

    I personally think this is a great exercise for getting your mind around how to design systems in Dreams.

Please sign in to leave a comment.