炮台旋转修改
This commit is contained in:
@@ -52,6 +52,7 @@ public class SitPosData : MonoBehaviour
|
||||
[Header("炮台")]
|
||||
[Tooltip("炮台实例化的父节点")]
|
||||
public Transform turretParent;
|
||||
public Transform turretRotate;
|
||||
|
||||
[Header("炮台控制模式")]
|
||||
[Tooltip("Normal=普通模式(动态克隆炮台,显示金币+钻石,按钮切换); XJMH=星际迷航模式(座位子对象激活/停用,只显示金币,长按扇形切换)")]
|
||||
@@ -277,6 +278,12 @@ public class SitPosData : MonoBehaviour
|
||||
{
|
||||
if (turret == null) return null;
|
||||
|
||||
// ⭐ 已分离旋转(用 turretRotate 旋转)时:tra_CurrTurret 只当【瞄准/位置锚点】,
|
||||
// 必须指向固定节点(turretRotate 的父节点),让瞄准用的 tra_CurrTurret.transform.parent
|
||||
// 不随旋转而变,否则瞄准参考系跟着转就会抖动。旋转由 turretRotate 负责。
|
||||
if (turretRotate != null)
|
||||
return turretRotate.parent != null ? turretRotate.parent : turretRotate;
|
||||
|
||||
// 优先用 TurretData 上配置的旋转节点
|
||||
if (turret.tra_RotationPivot != null)
|
||||
return turret.tra_RotationPivot;
|
||||
@@ -589,8 +596,9 @@ public class SitPosData : MonoBehaviour
|
||||
public void SetRotation(float angle)
|
||||
{
|
||||
currentAngle = angle;
|
||||
if (tra_CurrTurret != null)
|
||||
tra_CurrTurret.rotation = Quaternion.Euler(0, 0, angle);
|
||||
// ⭐ 炮台旋转只作用于 turretRotate(所有需要旋转的父对象),其余不改
|
||||
if (turretRotate != null)
|
||||
turretRotate.rotation = Quaternion.Euler(0, 0, angle);
|
||||
}
|
||||
|
||||
// -------------------------
|
||||
|
||||
Reference in New Issue
Block a user