Heroes_of_Hiis/Assets/Project Files/Scripts/Arlo/CuttableTree.cs

38 lines
785 B
C#
Raw Normal View History

2022-03-28 16:03:33 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2022-04-04 13:09:59 +00:00
using UnityEngine.Events;
2022-03-28 16:03:33 +00:00
public class CuttableTree : MonoBehaviour
{
private Quaternion rotation;
2022-04-04 13:09:59 +00:00
public GameObject stumpPrefab;
[SerializeField]
private UnityEvent onCut;
2022-03-28 16:03:33 +00:00
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Cutter")
{
rotation = transform.rotation;
rotation *= Quaternion.AngleAxis(20, Vector3.up);
2022-04-04 13:09:59 +00:00
Instantiate(stumpPrefab, transform.position, rotation);
2022-03-28 16:03:33 +00:00
Destroy(gameObject);
2022-04-04 13:09:59 +00:00
onCut.Invoke();
2022-03-28 16:03:33 +00:00
}
}
}