Instantiate particles with double if statement

Hello everyone, first time posting, as normally I can find the answers to my questions by searching around here. However, I have a project due Tuesday, and I can’t seem to find any help for this issue I’m having.

I’m making a game that involves mixing food into a pot, and depending on what ingredients you put in together, different particle systems will be emitted. As I’ve been building this up I’ve tested along the way, and I was able to get the particles to instantiate when I put in only one ingredient using OnCollisionEnter. However, I hit the problem of only being able to enter one argument into that function, so I switched to booleans and if statements instead. I have it set up so that the booleans are switched to true if the pot detects a collision with the corresponding object.

From there, I figured it’d be a very simple matter of checking if any given two booleans were true at the same time with a set of if statements, and then instantiating the desired particle system. However, I can’t seem to find a way to get this last step functioning. I’ve been Googling around and searching the forums for any particle instantiation tips I can find, and I’ve tried them all, but nothing seems to be working so far. I’m desperate for help, because this game is due in 2 days, and if I can’t get this to function, I won’t have a game at all!

EDIT: I should mention that I intended to put all of the particle systems into the array declared at the top, and instantiate them by calling on their array number down at the bottom.

Here is the code I’ve been testing with:

var prefab:GameObject[];

var apple:boolean = false;
var turkey:boolean = false;

function Update () 
{
	Shenanigans();
}


function OnCollisionEnter(ingredient:Collision)
{
	if(ingredient.gameObject.tag == "Apple")
	{
		apple = true;
	}
	if(ingredient.gameObject.tag == "Turkey")
	{
		turkey = true;
		
	}
}

function OnCollisionExit(ingredient:Collision)
{
	if(ingredient.gameObject.tag == "Apple")
	{
		apple = false;
		
	}
	if(ingredient.gameObject.tag == "Turkey")
	{
		turkey = false;
		
	}
}


function Shenanigans()
{
	if(apple && turkey)
	{
		Instantiate(prefab[0],transform.position,transform.rotation);
yield WaitForSeconds(5);
		Destroy(prefab[0]);
		return;
	}
}

Any help would be deeply appreciated!!

You may need to include more code but here’s my $.02

  1. You would need to check apple and turkey in an Update function, not just on Awake, but you could also do this OnCollisionEnter only.
  2. You could have the particle systems already there, just not active (not emitting) unless/until the collision happens.