Help Filling Box With Objects [like filling ballpit with balls]

Hello,

I am attempting to fill a "box" type object that I have with a prefab. To do this, just as a test, I created 5 semi transparent planes with Mesh Colliders [sides / bottom of box] and on scene load, spawned 50 items from an empty game object positioned near the bottom. The problem is, this is causing them to jump everywhere since they are hitting each other, and worse, they are for some reason going through my "sides" when to many items hit one area. I was wondering if there is a better way to go about filling up an area with an array of objects. I need to make sure I take Physics into consideration, since item's can not over lap. The best example would be filling a ball pit with balls.

Below is my coding I am using. I have this attached to an Empty game object, which is my spawn point:


public class FillPrizes : MonoBehaviour {

    private System.Collections.Generic.List balls = new System.Collections.Generic.List();

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {

        if (balls.Count < 50) { 

            GameObject current = (GameObject)Instantiate(Resources.Load("p_Balls"), transform.position, transform.rotation);
            balls.Add(current);

        }

    }

}

Hi,

I add a similar problem, and gave up... now that I think of it again, I would use a editing pre filling system.

During editing: build a script that spawn balls one at a time well above the pit, when you have your pit full, stop spawning balls and record the position of all your balls in an array, and save that array. Make sure you increase the collider size slightly when doing this pre filling to completly avoid overlapping later on.

During the game. Use that array to spawn them all at once in your actual game, and bring back the collider size to normal.

Hope that make sense :)

Bye,

Jean