C#: Using a class to make items with similar properties?

I’m making a 2D game in which fooddstuffs fall out of the sky and you try to catch them with your mouth. Each food item you catch will higher or lower your score, depending on the sort of food you catch.

Instead of making a prefab for each food item, I wanted to make one (spawner) prefab that changes properities… If that makes sense?

I’m pretty new to Unity and programming so I don’t know what is and isn’t possible yet. If any of you could help me out?

This is my food class so far:

public class Food {
	public int scoreAddition;
	public float scoreMultiply;
	public float speed;
	public Sprite sprite;
	public BoxCollider2D collider;
	
	public Food(int scA, float scM, float sp, Sprite spr, BoxCollider2D coll) {
		scoreAddition = scA;
		scoreMultiply = scM;
		speed = sp;
		sprite = spr;
		collider= coll;
	}
	
	void makeItem(Food food) {
		// ???
	}

}

Thanks in advance!

I think you’d be better off making different prefabs. Then just put them into an array and get a random food type using random.range and let the single spawner do the rest.

:slight_smile: