0906
This commit is contained in:
1 parent
5cd7a93c4a
commit
1476a089cb
108 files changed
+32073
-117261
No files matched your search
@@ -1,5 +1,3 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CameraFollow : MonoBehaviour
|
||||
@@ -8,15 +6,17 @@ public class CameraFollow : MonoBehaviour
|
||||
public Vector3 offset; // 摄像机相对于角色的偏移量
|
||||
public float smoothSpeed = 0.125f; // 摄像机移动的平滑速度
|
||||
|
||||
void LateUpdate()
|
||||
private void LateUpdate()
|
||||
{
|
||||
// // 计算摄像机应该到达的目标位置
|
||||
// Vector3 desiredPosition = target.position + offset;
|
||||
// // 使用Lerp方法平滑移动摄像机到目标位置
|
||||
// Vector3 smoothedPosition = Vector3.Lerp(transform.position, desiredPosition, smoothSpeed);
|
||||
// transform.position = smoothedPosition;
|
||||
if (target == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// // 让摄像机始终看向角色
|
||||
// transform.LookAt(target);
|
||||
Vector3 desiredPosition = target.position + offset;
|
||||
transform.position = Vector3.Lerp(
|
||||
transform.position,
|
||||
desiredPosition,
|
||||
smoothSpeed);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user