how to turn a particle emitter on & off with a rigidbody trigger?

Hi there,

I’m attempting to turn a waterfall on & off when the rock mesh is placed on top of it. When the rock is present, the emitter should be off, when the rock is not, the emitter should be on.

I have an invisible plane collider with the waterfall particle emitter attached as a child, I then have a rock-mesh with a rigidbody & collider attached to it, is trigger is also ticked on the rock.

I know I need to tag the rock, then tell the invisible plain “if the collision is true, turn off the emitter, if false turn on the emitter.” but I’m not so sure how to go about doing this as i’m pretty new to coding.

If anybody could shed some light on this I would really appreciate this.

Thanks.

[971-waterfall+collider.jpg|971]

Something like this on the waterfall collider object (in C#):

public ParticleEmitter myEmitter ; //then drag/drop the emitter on here in inspector
/** or if you don't want drag/drop it -->**/ ParticleEmitter myEmitter ;
/** if myEmitter isn't public drag/drop -->
void Start(){
   myEmitter = GetComponentInChildren<ParticleEmitter>() as ParticleEmitter ;
} <--**/

void OnTriggerEnter(Collider other){
   if(other.CompareTag("Rock"))
      myEmitter.emit = false ;
}

void OnTriggerExit(Collider other){
   if(other.CompareTag("Rock"))
      myEmitter.emit = true ;
}

Or if you want it on the rock… (in UnityScript):

var waterfall : ParticleEmitter ; //drag the waterfall emitter object on here

function OnTriggerEnter(other : Collider){
   if(other.CompareTag("WatefallTriggerPlaneThing"))
      waterfall.emit = false ;
}

function OnTriggerExit(other : Collider){
   if(other.CompareTag("WaterfallTriggerPlaneThing"))
      waterfall.emit = true ;
}

…somethin like that. All untested and I’m half-asleep again, but think I got it right (or at least close enough for you to get it figured out).

Actualy I’ve fixed that but the problem now is the Rock (Trigger) keeps falling through the floor, this is because is Trigger is ticked, when i remove the tick it doesnt fall through the floor but this obviously removes the trigger needed to turn on the emitter.

Any idea how I can go about fixing this?

Thanks.