quality-control/Assets/Scripts/Interactable/HammerableRigidbody.cs
2024-08-19 00:26:03 +02:00

29 lines
630 B
C#

using Nothke.Interaction;
using Nothke.Interaction.Items;
using UnityEngine;
public class HammerableRigidbody: RigidbodyInteractable
{
public override void Use(InteractionController im)
{
manager = im;
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);
clip.Play(
transform.position,
Random.Range(0.8f, 1.2f));
}
}