| | | 1 | | using System.Collections; |
| | | 2 | | using System.Collections.Generic; |
| | | 3 | | using UnityEngine; |
| | | 4 | | |
| | | 5 | | public class CubeInteractable : MonoBehaviour |
| | | 6 | | { |
| | | 7 | | |
| | | 8 | | [SerializeField] private Material newMaterial; |
| | | 9 | | |
| | | 10 | | // Start is called before the first frame update |
| | | 11 | | void Start() |
| | 0 | 12 | | { |
| | | 13 | | |
| | 0 | 14 | | } |
| | | 15 | | |
| | | 16 | | // Update is called once per frame |
| | | 17 | | void Update() |
| | 0 | 18 | | { |
| | | 19 | | |
| | 0 | 20 | | } |
| | | 21 | | |
| | | 22 | | private void OnCollisionEnter(Collision collision) //Un appel par collision, donc si l'objet touche 6 autres objets, |
| | 0 | 23 | | { |
| | | 24 | | |
| | 0 | 25 | | if (collision.gameObject.layer == LayerMask.NameToLayer("Platform") ) |
| | 0 | 26 | | { |
| | 0 | 27 | | if (collision.gameObject.GetComponent<Renderer>().sharedMaterial == this.gameObject.GetComponent<Renderer>() |
| | | 28 | | |
| | 0 | 29 | | { |
| | 0 | 30 | | Destroy(this.gameObject); |
| | 0 | 31 | | } |
| | | 32 | | else |
| | 0 | 33 | | { |
| | 0 | 34 | | collision.gameObject.GetComponent<Renderer>().material = newMaterial; |
| | 0 | 35 | | } |
| | 0 | 36 | | } |
| | 0 | 37 | | } |
| | | 38 | | } |