SHOW:
|
|
- or go back to the newest paste.
| 1 | using System.Collections; | |
| 2 | using System.Collections.Generic; | |
| 3 | using UnityEngine; | |
| 4 | ||
| 5 | public class VechicleDestructionTrigger : MonoBehaviour | |
| 6 | {
| |
| 7 | public bool activeOnStay; | |
| 8 | void OnTriggerEnter(Collider collider){
| |
| 9 | if (collider.GetComponent<Explosided>())/// | |
| 10 | collider.GetComponent<Explosided>().Explode();///Если обьект целый - заменить на разломанный с rigidBody.isKinematic = true на каждом обломке | |
| 11 | if (collider.tag == "Obstacle" && collider.gameObject.GetComponent<Rigidbody>()) | |
| 12 | collider.GetComponent<Rigidbody>().isKinematic = false;}//Add physics | |
| 13 | //Дальше машина по идеи просто врезается в эту стену и обломки разлетаются | |
| 14 | void OnTriggerStay(Collider collider) | |
| 15 | {
| |
| 16 | if (activeOnStay) {
| |
| 17 | if (collider.GetComponent<Explosided>()) | |
| 18 | collider.GetComponent<Explosided>().Explode(); | |
| 19 | if (collider.tag == "Obstacle" && collider.gameObject.GetComponent<Rigidbody>()) | |
| 20 | collider.GetComponent<Rigidbody>().isKinematic = false;} | |
| 21 | }//Это не нужно(проверял "может надо не на входе а на удержании в триггере") | |
| 22 | } |