2024-08-17 13:12:00 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class ProductReceiver : MonoBehaviour
|
|
|
|
{
|
|
|
|
///HashSet<Rigidbody> enteredBodies = new HashSet<Rigidbody>();
|
|
|
|
|
|
|
|
public int normalProductCount;
|
|
|
|
public int defectiveProductCount;
|
|
|
|
|
|
|
|
private void OnCollisionEnter(Collision collision)
|
|
|
|
{
|
|
|
|
var rb = collision.rigidbody;
|
|
|
|
|
|
|
|
if (!rb)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//enteredBodies.Add(rb);
|
2024-08-18 12:44:44 +00:00
|
|
|
|
|
|
|
if (rb.TryGetComponent(out Product product))
|
2024-08-17 13:12:00 +00:00
|
|
|
{
|
2024-08-18 12:44:44 +00:00
|
|
|
if (product.Defect != DefectType.None)
|
|
|
|
{
|
|
|
|
defectiveProductCount++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
normalProductCount++;
|
|
|
|
}
|
2024-08-17 13:12:00 +00:00
|
|
|
|
2024-08-18 12:44:44 +00:00
|
|
|
Destroy(rb.gameObject);
|
|
|
|
}
|
2024-08-17 13:12:00 +00:00
|
|
|
}
|
|
|
|
}
|