Answer the question
In order to leave comments, you need to log in
How to find out which objects are in contact with the collider at the moment?
There is an OnTrigger event. There are districts. Is it possible in a certain place in the code to poll the collider after receiving a list of hits? To find out which objects currently have contact with the collider?
Or there are no ready-made solutions and this is possible only by implementing a certain sheet where objects will be written and deleted by OnTrigger events?
Answer the question
In order to leave comments, you need to log in
Thanks to @ShockWave2048 I found the OverlapBox function nearby
void MyCollisions()
{
//Use the OverlapBox to detect if there are any other colliders within this box area.
//Use the GameObject's centre, half the size (as a radius) and rotation. This creates an invisible box around your GameObject.
Collider[] hitColliders = Physics.OverlapBox(gameObject.transform.position, transform.localScale / 2, Quaternion.identity, m_LayerMask);
int i = 0;
//Check when there is a new collider coming into contact with the box
while (i < hitColliders.Length)
{
//Output all of the collider names
Debug.Log("Hit : " + hitColliders[i].name + i);
//Increase the number of Colliders in the array
i++;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question