private void FixedUpdate() { timeSpent += Time.deltaTime; if (timeSpent > SpawnRate && currentPickups.Count < maxPickups) { GameObject tmp = Instantiate(Pickup); Pickups currentPickup = tmp.GetComponent <Pickups>(); currentPickup.setPlayer(Player); timeSpent = 0; currentPickups.Add(currentPickup); currentPickup.transform.position = new Vector2((float)randomSign() * Random.Range(2.5f, 5), (float)randomSign() * Random.Range(2.5f, 5)); } nbOfPickups = currentPickups.Count; }
// Start is called before the first frame update void Start() { parent = GetComponentInParent <Pickups>(); }