コード例 #1
0
        private void Update()
        {
            if (paused)
            {
                return;
            }

            if (!moveByPhysics)
            {
                if (moving)
                {
                    Vector3 newPos = transform.position;
                    if (t < 1)
                    {
                        t += Time.deltaTime / moveTime;

                        newPos = Vector3.Lerp(startPos, targetPos, t);
                    }
                    else
                    {
                        moving = false;
                    }

                    if (useConstraints)
                    {
                        newPos = constraints.ApplyConstraints(newPos);
                    }

                    transform.position = newPos;
                }

                if (rotating)
                {
                    Quaternion newRot = transform.rotation;
                    if (tRot < 1)
                    {
                        tRot += Time.deltaTime / rotTime;

                        newRot = Quaternion.Slerp(startRot, targetRot, tRot);
                    }
                    else
                    {
                        rotating = false;
                    }

                    transform.rotation = newRot;
                }
            }
        }