| | | 1 | | using System.Collections; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using TMPro; |
| | | 4 | | using UnityEngine; |
| | | 5 | | |
| | | 6 | | public class BallSoundController : MonoBehaviour |
| | | 7 | | { |
| | 21 | 8 | | public float peso=0.7f; |
| | 21 | 9 | | public int pesoEnKgs=7; |
| | 21 | 10 | | private bool hasPlayed = false; |
| | | 11 | | |
| | | 12 | | public TextMeshProUGUI textoPeso; |
| | | 13 | | |
| | | 14 | | private void Start() |
| | 7 | 15 | | { |
| | 7 | 16 | | changePeso(); |
| | 7 | 17 | | } |
| | | 18 | | |
| | | 19 | | public void changePeso() |
| | 7 | 20 | | { |
| | 7 | 21 | | this.GetComponent<Rigidbody>().mass = peso; |
| | 7 | 22 | | textoPeso.text = pesoEnKgs.ToString() + "KG"; |
| | 7 | 23 | | } |
| | | 24 | | |
| | | 25 | | private void OnCollisionEnter(Collision collision) |
| | 9 | 26 | | { |
| | 9 | 27 | | if (collision.gameObject.CompareTag("Bolo") && hasPlayed==false) |
| | 0 | 28 | | { |
| | 0 | 29 | | hasPlayed = true; |
| | 0 | 30 | | gameObject.GetComponent<AudioSource>().Play(); |
| | 0 | 31 | | } |
| | 9 | 32 | | } |
| | | 33 | | } |