winngman
This commit is contained in:
parent
f9bded8800
commit
05fa2ede36
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user