//运动 public void Move(float current_time, float speed_rate, float delta_time) { if (TimeRate(current_time) > 1.001f || current_time > EndTime) { return; } else { lastFrameTime = current_time; } if (CurrentMotion == CameraMotionType.Line) //直线 { CurrentCamera.transform.position = StartPos + SpeedVector * (current_time - StartTime) * speed_rate; if (HasSizeChange) { SetCameraPortValue(StartSize + SizeSpeed * (current_time - StartTime) * speed_rate); } if (needExcess) { if (TimeRate(current_time) <= 0.1f) { CurrentCamera.transform.eulerAngles = Vector3.Lerp(diffVector[0], diffVector[1], TimeRate(current_time) * 10f); } else { CurrentCamera.transform.LookAt(TargetTrans); } } else { CurrentCamera.transform.LookAt(TargetTrans); } } else if (CurrentMotion == CameraMotionType.Circular) //圆弧 { CurrentCamera.transform.RotateAround(RotateCenter, RotateAxis, RotateSpeed * delta_time * speed_rate); if (HasSizeChange) { SetCameraPortValue(StartSize + SizeSpeed * (current_time - StartTime) * speed_rate); } CurrentCamera.transform.LookAt(TargetTrans); } else //可视化路径运动 { CurrentCamera.transform.position = crSpline.Interp(TimeRate(current_time)); if (TargetTrans != null) { if (needExcess) { if (TimeRate(current_time) <= 0.1f) { CurrentCamera.transform.eulerAngles = Vector3.Lerp(diffVector[0], diffVector[1], TimeRate(current_time) * 10f); } else { CurrentCamera.transform.LookAt(TargetTrans); } } else { CurrentCamera.transform.LookAt(TargetTrans); } SetCameraPortValue(crSpline.ViewLerp(TimeRate(current_time))); } else { CurrentCamera.transform.eulerAngles = crSpline.EulerAngleLerp(TimeRate(current_time), ref currentIndex, ref viewTimeRate); //二分法查找算一次 SetCameraPortValue(Mathf.Lerp(crSpline.cameraViewList[currentIndex], crSpline.cameraViewList[currentIndex + 1], viewTimeRate)); } } }