Esempio n. 1
0
    public void StartFollowTransform(Transform t, bool moveLerp, float moveSpeed = 0.5f)
    {
        if (moveLerp)
        {
            SetControlMode(CameraControlMode.DisableControl);
        }
        //然后移动到目标点,然后进行最终设定
        targetTransform = t;
        Vector3 p = PositionMath.CameraLocalPositionFollowUnitLocalPosition(targetTransform.localPosition);

        if (p == targetTransform.localPosition)
        {
            SetControlMode(CameraControlMode.FollowTransform);
            return;
        }
        float distance = moveSpeed / Vector3.Distance(p, transform.localPosition);

        StartCoroutine(IMoveCameraToTarget(p, distance, () => SetControlMode(CameraControlMode.FollowTransform)));
    }
Esempio n. 2
0
    public void CameraFollowTargetPosition()
    {
        Vector3 p = PositionMath.CameraLocalPositionFollowUnitLocalPosition(targetTransform.localPosition);

        transform.localPosition = p;
    }