I want to create a card game like UNO, where there is a card in play and the card plaid has to match the type of card on the table.
Who would I go about assigning different attributes to a card? Would I make several tags for each card?
I want to create a card game like UNO, where there is a card in play and the card plaid has to match the type of card on the table.
Who would I go about assigning different attributes to a card? Would I make several tags for each card?
There’s many ways to set up a ‘type’. I would not recommend relying on Unity Tags. My favorite way is to create an Enum.
Examples:
public class Card : MonoBehaviour
{
public enum Type
{
Normal,
Special
}
// can be assigned as a dropdown menu in the inspector
public Type type;
}
public class OtherClass : MonoBehaviour
{
public void CardComparisonFunction(Card card1, Card card2)
{
if(card1.type == card2.type)
{
Debug.Log("They're the same card type");
}
}
public void DoAThingWithACard(Card card)
{
// do something special depending on what type it is
switch(card.type)
{
case Card.Type.Normal:
Debug.Log("Did a normal thing");
break;
case Card.Type.Special:
Debug.Log("Did a special thing");
break;
default:
Debug.Log("That was not a card.");
break;
}
}
}