_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/RacingPanel/CameraAutoMove.cs
2024-12-05 15:48:55 +08:00

17 lines
540 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using DG.Tweening; // 引入 DOTween 命名空间
public class CameraAutoMove : MonoBehaviour
{
public GameObject targetPos;//目标位置
public float targetXPosition = 10f; // 目标位置的X轴坐标
public float moveDuration; // 平移持续时间
void Start()
{
// 使用 DOTween 实现平移动画
// 目标位置:当前位置的 Y 和 Z 值不变X 值设定为 targetXPosition
transform.DOMoveX(targetPos.transform.position.x, moveDuration)
.SetEase(Ease.Linear); // 线性过渡,平稳的平移
}
}