- Home /
How to GetComponent from another Gameobject OnTriggerEnter
Hey guys-
I have a container of water I want to fill up when water particles enter it.
Right now, I've enabled collisions on my water particles. The waterContainer object is just a BoxCollider set to isTrigger. I tried putting this script on the waterparticlesystem but obviously it did not work because you can't getComponents from colliders:
void OnParticleTrigger (Collider other)
{
other.GetComponent<waterContainerScript>().AddWater();
}
Does anyone know how to GetComponent from the object you are triggering??
Answer by bhavinbhai2707 · Jan 21, 2018 at 07:16 PM
you can apply a script in the box collider with trigger on and store a public bool value in it and once the Trigger is altered then simply make the bool true suppose somethingEntered = true; and then access this bool from other scripts.
Normally this would work, but unfortunately it seems that when you use collisions on particles, they don't register with normal triggers
Your answer
![](https://koobas.hobune.stream/wayback/20220612151017im_/https://answers.unity.com/themes/thub/images/avi.jpg)