fix:代码提交
This commit is contained in:
@@ -8,7 +8,6 @@ using UnityEngine.AI;
|
||||
using System.Linq;
|
||||
public class CameraRover : ActionBase
|
||||
{
|
||||
private CameraControl cameraCtr2;
|
||||
private ControlMove cameraCtrl;
|
||||
private Vector3 targetPos = Vector3.zero; //视角坐标
|
||||
|
||||
@@ -32,14 +31,19 @@ public class CameraRover : ActionBase
|
||||
|
||||
public LayerMask obstacleLayer; // 障碍物层
|
||||
|
||||
|
||||
void Awake()
|
||||
{
|
||||
// 确保初始化方法被调用,避免cameraCtrl为空
|
||||
if (cameraCtrl == null)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
cameraCtr2 = GetComponent<CameraControl>();
|
||||
cameraCtrl = GetComponent<ControlMove>();
|
||||
|
||||
|
||||
Debug.Log(cameraCtrl);
|
||||
currentAnim = "";
|
||||
isLookAt = false;
|
||||
}
|
||||
@@ -83,12 +87,12 @@ public class CameraRover : ActionBase
|
||||
|
||||
void StartCameraCtrl()
|
||||
{
|
||||
cameraCtr2.StartCameraControl();
|
||||
cameraCtrl.StartCameraControl();
|
||||
}
|
||||
|
||||
void StopCameraCtrl()
|
||||
{
|
||||
cameraCtr2.StopCameraControl();
|
||||
cameraCtrl.StopCameraControl();
|
||||
}
|
||||
|
||||
public void SetTargetPosition(Vector3 position)
|
||||
@@ -111,8 +115,8 @@ public class CameraRover : ActionBase
|
||||
StopCameraCtrl();
|
||||
cameraCtrl.GetInScriptCore();
|
||||
yield return new WaitForEndOfFrame();
|
||||
transform.DOMove(new Vector3(1828.729f, 158.0276f, 635.7281f), 2f);
|
||||
transform.DORotate(new Vector3(29.401f, -22.4f, 0f), 2f);
|
||||
transform.DOMove(new Vector3(-84.34684f, 16.32042f, 21.03517f), 2f);
|
||||
transform.DORotate(new Vector3(12.927f, -178.316f, 0f), 2f);
|
||||
yield return new WaitForSeconds(2f);
|
||||
StartCameraCtrl();
|
||||
}
|
||||
@@ -205,6 +209,8 @@ public class CameraRover : ActionBase
|
||||
|
||||
flightTime = Mathf.Max(flightTime, 0.1f);
|
||||
flightTime = Mathf.Min(flightTime, maxFlightTime);
|
||||
|
||||
|
||||
RaycastHit hit;
|
||||
// 射线检测是否有障碍物
|
||||
if (Physics.Raycast(transform.position, targetPosition - transform.position, out hit, distance, obstacleLayer))
|
||||
|
||||
Reference in New Issue
Block a user