Hi, so here’s my code below. I’m making a blackjack game. At about 20% through the deck, it plays the yellow card, which means once this hand is done, all the cards will be reshuffled. Anyway, what I want is for it to deal the yellow card, then the yellow card moves up to the top corner, and it continues on dealing the rest of the hand. However, what’s happening is that it’s dealing the yellow card and the card after at the same time. Or fast enough that it seems like it’s at the same time.
So right now I put a hold for 5 seconds after the yellow card is dealt, just so i can see if it’s working. The debug text does work. It shows the before text, then the after text 5 seconds later. But I can’t seem to get it to wait the 5 seconds to deal the next card. Anyone see something I’m doing wrong? The code works exactly how I want it to right now, except I can’t seem to make the pause happen.
function Yellow()
{
yellowCard = Instantiate(yellow, dealYellowCard.transform.position, dealYellowCard.transform.rotation);
yellowCard.name = "yellow";
yield WaitForSeconds(1);
yellowCard.transform.position = holdYellowCard.transform.position;
}
function HoldYellow()
{
print("Before 5 Seconds");
yield WaitForSeconds(5);
print("After 5 Seconds");
}
function DealCard() : GameObject
{
if(yellowPlayed == true dealReady == true)
{
ResetDeck();
}
totalCards = numDecks * 52;
twentyPercent = totalCards * 0.2;
if(cards.Count == twentyPercent yellowPlayed == false)
{
Yellow();
HoldYellow();
yellowPlayed = true;
card = Random.Range(0, cards.Count);
go = GameObject.Instantiate(cards[card]) as GameObject;
cards.RemoveAt(card);
return go;
}
else
{
card = Random.Range(0, cards.Count);
go = GameObject.Instantiate(cards[card]) as GameObject;
cards.RemoveAt(card);
return go;
}
}