| | | 1 | | using System.Collections; |
| | | 2 | | using TMPro; |
| | | 3 | | using UnityEngine; |
| | | 4 | | |
| | | 5 | | public class OtherLaneController : MonoBehaviour |
| | | 6 | | { |
| | | 7 | | public Transform aparicionBola; |
| | | 8 | | public GameObject bolaPrefab; |
| | | 9 | | |
| | | 10 | | private IEnumerator OnTriggerEnter(Collider other) |
| | 119 | 11 | | { |
| | 119 | 12 | | yield return new WaitForSeconds(5); |
| | 54 | 13 | | if (other.tag == "Ball") |
| | 0 | 14 | | { |
| | 0 | 15 | | var peso = other.GetComponent<BallSoundController>().peso; |
| | 0 | 16 | | var pesoEnKgs = other.GetComponent<BallSoundController>().pesoEnKgs; |
| | | 17 | | |
| | | 18 | | |
| | | 19 | | //Se destruye la bola |
| | 0 | 20 | | Destroy(other.gameObject); |
| | | 21 | | |
| | | 22 | | |
| | 0 | 23 | | GeneraBola(bolaPrefab, pesoEnKgs, peso); |
| | 0 | 24 | | } |
| | 54 | 25 | | } |
| | | 26 | | |
| | | 27 | | private void GeneraBola(GameObject bola, int pesoKgs, float peso) |
| | 0 | 28 | | { |
| | 0 | 29 | | var bolaControll = bola.GetComponent<BallSoundController>(); |
| | 0 | 30 | | bolaControll.peso = peso; |
| | 0 | 31 | | bolaControll.pesoEnKgs = pesoKgs; |
| | 0 | 32 | | bolaControll.changePeso(); |
| | | 33 | | |
| | 0 | 34 | | var miBola = Instantiate(bola, aparicionBola.position, aparicionBola.rotation); |
| | 0 | 35 | | miBola.GetComponent<Rigidbody>().AddForce(new Vector3(1, 0, 0) * 1.5f, ForceMode.Impulse); |
| | 0 | 36 | | } |
| | | 37 | | |
| | | 38 | | } |