示例#1
0
    void StartSingleExperiment()
    {
        Debug.Log($"Starting experiment ({_repeatsRemaining} remaining) \n {Parameters.CurrentValuesString()}");
        _repeatsRemaining--;

        _boxHeight          = 0;
        _currentStackHeight = 1f;


        int placeNow = _stackOneByOne ? 1 : _numberOfBoxes;

        _boxesPlaced = 0;
        while (_boxesPlaced < placeNow)
        {
            var box = AddBox();
            // Do some stuff after adding the first box
            if (_boxesPlaced == 1)
            {
                var physicMaterial = box.GetComponent <Collider>().sharedMaterial;
                physicMaterial.dynamicFriction = _friction;
                physicMaterial.staticFriction  = _friction;
                _boxHeight      = GetTotalColliderSize(box).y;
                box.isKinematic = true;
            }
        }


        _experimentRunning = true;
        _runningFrames     = 0;

        /*
         * Position camera
         */
        var total  = _boxHeight * _numberOfBoxes;
        var camPos = new Vector3(total * 0.75f, total, total * 1.25f);

        Camera.main.transform.position = camPos;
        Camera.main.transform.LookAt(new Vector3(0, total * 0.3f, 0));
    }