test commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
public class TreeFallTrigger : MonoBehaviour
|
||||
{
|
||||
AudioSource source;
|
||||
Animation anim;
|
||||
|
||||
bool fell = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
source = GetComponent<AudioSource>();
|
||||
anim = GetComponent<Animation>();
|
||||
if (!anim)
|
||||
anim = GetComponentInParent<Animation>();
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (Random.Range(0, 100) < 50) return;
|
||||
|
||||
if (other.CompareTag("Player") && !fell)
|
||||
{
|
||||
fell = true;
|
||||
|
||||
if (!anim || !source) return;
|
||||
|
||||
anim.Play("fall");
|
||||
source.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef339f08da140604cb439333b2b4beba
|
||||
Reference in New Issue
Block a user