quality-control/Assets/Scripts/Interactable/HammerableRigidbody.cs

29 lines
630 B
C#
Raw Normal View History

2024-08-18 15:48:35 +00:00
using Nothke.Interaction;
using Nothke.Interaction.Items;
using UnityEngine;
public class HammerableRigidbody: RigidbodyInteractable
{
public override void Use(InteractionController im)
{
2024-08-18 17:27:27 +00:00
manager = im;
2024-08-18 15:48:35 +00:00
if (im.hands.item == null)
{
base.Use(im);
return;
}
var product = GetComponentInChildren<Product>();
if (!product)
{
return;
}
var clip = product.Type.SelectClip(product.Defect != DefectType.None);
2024-08-18 22:26:03 +00:00
clip.Play(
transform.position,
Random.Range(0.8f, 1.2f));
2024-08-18 15:48:35 +00:00
}
}