I am attempting to make a system where each card spawns in from off screen (doesn’t matter much yet) shows itself off in center screen and then moves downward and into your hand of cards.
None of that really pertains much to my question other than the fact that I need the card to pause upon reaching center-screen.
For now I was just testing yield return new WaitForSeconds(whatever float);
but it seems to just crash unity regrades of how I try an implement it into my code.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TimeLord : MonoBehaviour
{
public List<GameObject> numbr = new List<GameObject>();
private int numbrTwo = 7;
public GameObject placeholder;
public GameObject prefab;
public void Start()
{
do
{
StartCoroutine(Enterhand());
}
while (numbr.Count < numbrTwo);
}
public IEnumerator Enterhand()
{
yield return new WaitForSeconds(.3f);
placeholder = Instantiate(prefab, new Vector3((0 + numbr.Count), 0, -1), Quaternion.identity);
numbr.Add(placeholder);
}
}
I’ve tried to solve this myself. I promise I’ve been searching every forum I can think of, but this is my first script even touching IEnumerator
s so I am certain it’s probably obvious to the average dev.
(disclaimer, this is not the actual code I was originally working with, I had a lot more variables and MonoBehavior
s but I stripped everything else out line by line to see if it was the problem and it really is just this.)