- Home /
click first, click second, destroy if matched
Hi,I have a piece of code that generates 56 random cards. At the moment are visible. I want to click on one, click on a second one and if they are the same, destroy them and replace them with new ones. I thought about something like:
generate all 6 cards
click on the first cards
click on the second card
if first card == the second card
store first one spawn point
store second one spawn point
destroy both
generate and instantiate one card in one stored spawn point
generate and instantiate second card in the other stored spawn point
The problem, is I don't exactly now how to select the objects and compare them. Any suggestions?
Do you have any parts of this working yet? Just make it so you can deal the cards and select one. Get it so selecting another unselects the first.
Then it's just a program$$anonymous$$g problem. Think of it like GameObject selected1, selected2;
Answer by Doodayer · Jul 06, 2015 at 02:00 AM
Use onClick(); with an if statement that checks to see if the two cards are a match. That's the simplest answer, assuming that your current code creates the same card object. Might help to post what you have so far.
Your answer

Follow this Question
Related Questions
GameObject becomes 'unselectable' 1 Answer
Need help selecting a game Object to move it 1 Answer
selected object in array lost in translation 0 Answers
Some Copies of Prefab Detect Clicks But Others Don't 1 Answer
Is there a way to click on a render texture to select soemthing within the view? 4 Answers