By unity document, OnTriggerEnter occurs on the FixedUpdate after a collision.
When I click a button, this happens
…
triggger3 ngot3 = ngo.AddComponent<triggger3>();
print(ngot3.gos.Count);
…
where triggger3 is:
public class triggger3 : MonoBehaviour {
public List<GameObject> gos = new List<GameObject>();
void OnTriggerEnter(Collider other)
{
gos.Add(other.gameObject);
}
}
What I want is to get all GameObjects overlapping ngo(GameObject) immediately.
However, “print(ngot3.gos.Count)” always print “0” because OnTriggerEnter haven’t happened until the next fixedUpdate.
Is there any ways to let OnTriggerEnter occurs immediately or other ways to find gameObjects overlapping a mesh?