Exemplo n.º 1
0
        private void Update()
        {
            var sec = 2.0f;

            if (_startAlignRotation)
            {
                _curTime += Time.deltaTime;
                var tm = Mathf.Clamp(_curTime / sec, 0f, 1f);

                transform.eulerAngles = Vector3.Lerp(initProps.Rot.eulerAngles, _targetRotation, tm);

                transform.position = Vector3.Lerp(initProps.Pos, _targetPosition - (selectedTris.MiddlePointGlobal - transform.position), tm);

                if (Math.Abs(tm - 1f) < 0.00001)
                {
                    _startAlignRotation = false;
                    _curTime            = 0f;

                    // selectedTris.Debug(selectedTris.NormalGlobal.ToString(), Color.magenta, 30);
                    _planeManager.MovePlaneAlong(transform.position, selectedTris.NormalGlobal);
                    var ldta = gameObject.AddComponent <LeanDragTranslateAlong>();
                    ldta.ScreenDepth = new LeanScreenDepth()
                    {
                        Conversion = LeanScreenDepth.ConversionType.PlaneIntercept,
                        Object     = _planeManager.GetComponent <LeanPlane>()
                    };
                }
            }
        }