private void InitBall() { Vector3 posicionBarra = barra.Instance.gameObject.transform.position; Vector3 startingPosition = new Vector3(posicionBarra.x, posicionBarra.y + .27f, 0); pelota_inicial = Instantiate(pelota_Prefab, startingPosition, Quaternion.identity); pelotaInicialRB = pelota_inicial.GetComponent <Rigidbody2D>(); this.pelotas = new List <Pelota> { pelota_inicial }; }
public void SpawnBalls(Vector3 position, int count, bool isLightningBall) { for (int i = 0; i < count; i++) { Pelota spawnedBall = Instantiate(pelota_Prefab, position, Quaternion.identity) as Pelota; if (isLightningBall) { spawnedBall.StartLightningBall(); } Rigidbody2D spawnedBallRB = spawnedBall.GetComponent <Rigidbody2D>(); spawnedBallRB.isKinematic = false; spawnedBallRB.AddForce(new Vector2(0, velocidadPelotaInicial)); this.pelotas.Add(spawnedBall); } }