Beispiel #1
0
    protected void tickSteering()
    {
        if (isMoving)
        {
            float t = moveSpeed / moveStepDistance;
            moveLerpFactor += (Time.deltaTime * t);
            if (moveLerpFactor > 1.0f)
            {
                moveLerpFactor = 1.0f;
            }
            transform.localPosition = Vector3.Lerp(siteStartToMove, targetToMove, moveLerpFactor);
            if (moveLerpFactor == 1.0f)
            {
                isMoving = false;
            }
        }

        if (isRotating)
        {
            float spinFactor = 0.0f;
            currentOrientation = TurretController.cuteRotate(currentOrientation, targetToRotate, rotateSpeed, out spinFactor);
            if (spinFactor == 0.0f)
            {
                isRotating = false;
            }
            else
            {
                isRotating = true;
            }

            transform.localRotation = Quaternion.Euler(0, currentOrientation, 0);
        }
    }