using System.Collections; using System.Collections.Generic; using UnityEngine; public class ScaleZone : MonoBehaviour { private List _objects = new List(); private void OnTriggerEnter(Collider other) { Rigidbody rb = other.GetComponentInParent(); if (rb == null) return; if (!rb.CompareTag("Target")) return; if (!_objects.Contains(rb)) _objects.Add(rb); } private void OnTriggerExit(Collider other) { Rigidbody rb = other.GetComponentInParent(); if (rb == null) return; _objects.Remove(rb); } public float TotalWeight { get { float total = 0f; foreach (var rb in _objects) { if (rb != null) total += rb.mass; } return total; } } }