using System.Collections; using System.Collections.Generic; using UnityEngine; // Use Script in parent Folder of all humans public class ChangeMaterial : MonoBehaviour { public Material highlightRed; public Material highlightGreen; private Vector3 center; // Needed size divided with 2, bc all humans have the same radius (would be twice as big) private float radius = 0.5f; // Start is called before the first frame update void Start() { // Gets all Transform components to get the position of them Component[] allTransformComponent = GetComponentsInChildren(); //this.GetComponent().material = highlightRed; foreach(Transform transform in allTransformComponent) { center = transform.position; createCollisionSpheres(center, radius); } //center = this.GetComponent().position; } private void createCollisionSpheres(Vector3 center, float radius) { // !!!!!!!!! use OverlapSphereNonAlloc instead Collider[] objectsColliding = Physics.OverlapSphere(center, radius); foreach(var coll in objectsColliding) { coll.SendMessage("Collision"); } } private void Update() { } }