Files
DougDiggem/Assets/Scripts/Shovel.cs
T

22 lines
455 B
C#

using UnityEngine;
public class Shovel : MonoBehaviour
{
public Animator shovelAnimator;
public void Dig()
{
shovelAnimator.SetTrigger("Dig");
}
// this only works if this script is sitting on the object with the collider!!
private void OnTriggerEnter(Collider other)
{
Diggable diggable = other.GetComponent<Diggable>();
if (diggable != null)
{
diggable.Dig();
}
}
}