feat(Connect Distance): 添加了玩家最大可连接距离的逻辑
This commit is contained in:
@@ -11,6 +11,7 @@ namespace Script.Gameplay.Player
|
||||
{
|
||||
public bool IsEnableConnecting = true; // 是否启用连接功能
|
||||
[SerializeField] private FirstPersonRaycaster raycaster; // 第一人称射线检测器
|
||||
[SerializeField] private float maxConnectDistance = 10f; // 最大连接距离
|
||||
|
||||
private IConnectable currentTarget; // 当前注视的可连接对象
|
||||
private IConnectable previousGazedTarget; // 上一次注视的 IConnectable(用于触发进入/离开)
|
||||
@@ -111,6 +112,14 @@ namespace Script.Gameplay.Player
|
||||
if(!IsEnableConnecting) return;
|
||||
if (outTarget != null && inputTarget != null && outTarget != inputTarget)
|
||||
{
|
||||
//计算距离
|
||||
float distance = Vector3.Distance(outTarget.GetPosition(), inputTarget.GetPosition());
|
||||
if (distance > maxConnectDistance)
|
||||
{
|
||||
Debug.Log("Cannot create connection: targets are too far apart.");
|
||||
return;
|
||||
}
|
||||
// 创建连接线
|
||||
ConnectionLine connectionLine = ConnectionLineManager.Instance.GenerateConnectionLine(outTarget, inputTarget);
|
||||
outTarget.OutputConnectionLine = connectionLine;
|
||||
inputTarget.InputConnectionLine = connectionLine;
|
||||
|
Reference in New Issue
Block a user