Search Unity

Scaling trigger when particles enter

Discussion in 'Scripting' started by thestrandedmoose, Feb 15, 2018.

  1. thestrandedmoose

    thestrandedmoose

    Joined:
    Jul 21, 2015
    Posts:
    70
    Hi Unity Community!
    I want to scale a trigger up in Y when OnParticleTrigger (i.e.: a pool filling with water when water particles enter)
    I've figured out how to do it OnParticleCollision, but the problem is, I need my player to be able to enter the pool and swim (this is why a trigger would be preferred). OnParticleCollision only works for non-trigger colliders

    Code (CSharp):
    1. void OnParticleCollision (GameObject other)
    2.     {//This checks if our colliding object is a water container
    3.         if (other.GetComponent<waterContainerScript> () != null) {
    4. //This adds water to our container (scales up in Y)
    5.             other.GetComponent<waterContainerScript> ().AddWater ();
    6.         }
    7. }
    8.  
    I checked out the OnParticleTrigger documentation, but it only talks about changing particles within a trigger, not modifying the trigger itself. Does anyone know how I could achieve this?