From 05fa2ede366b815d8caa1729d9bb48721487d953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E5=8F=B7=E6=95=AC?= <153802103@qq.com> Date: Wed, 27 Nov 2024 20:21:19 +0800 Subject: [PATCH] winngman --- Assets/scripts/WingmanController.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Assets/scripts/WingmanController.cs b/Assets/scripts/WingmanController.cs index b16fbbdb..15278540 100644 --- a/Assets/scripts/WingmanController.cs +++ b/Assets/scripts/WingmanController.cs @@ -58,7 +58,7 @@ public class WingmanController : MonoBehaviour // 让僚机跟随主机 FollowPlayer(); - target = FindClosestEnemy().transform; + // 让僚机开火 @@ -83,19 +83,17 @@ public class WingmanController : MonoBehaviour // 僚机发射导弹 private void FireMissile() { - // 创建导弹并发射 - GameObject missile = Instantiate(missilePrefab, missileSpawnPoint.position, missileSpawnPoint.rotation); + target = FindClosestEnemy().transform; + //Todo僚机追踪子弹 if (target != null) { - // 旋转导弹朝向目标 + GameObject missile = Instantiate(missilePrefab, missileSpawnPoint.position, missileSpawnPoint.rotation); Vector3 direction = target.position - missile.transform.position; Quaternion targetRotation = Quaternion.LookRotation(direction); missile.transform.rotation = targetRotation; - float distance = Vector3.Distance(missile.transform.position, target.position); float moveDuration = Mathf.Clamp(distance / 20f, 0.2f, 0.7f); - // 向目标前进 missile.transform.DOMove(target.position, moveDuration); } }