using System.Collections; using System.Collections.Generic; using UnityEngine; public class CuttableTree : MonoBehaviour { private Quaternion rotation; public GameObject myPrefab; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { } void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Cutter") { Instantiate(myPrefab, transform.position, transform.rotation); Destroy(gameObject); } } void OnTriggerEnter(Collider other) { if (other.tag == "Cutter") { rotation = transform.rotation; rotation *= Quaternion.AngleAxis(20, Vector3.up); Instantiate(myPrefab, transform.position, rotation); Destroy(gameObject); } } }