This commit is contained in:
YangHua 2024-01-21 13:14:42 +08:00
parent a306bcad2c
commit 184a763763
3 changed files with 14 additions and 6 deletions

View File

@ -7,6 +7,7 @@ public class ShellBoom : MonoBehaviour
{
public UnityEvent onShellAttack = new UnityEvent();
public bool isPlayer = false;
public Transform attackTarget;
private void OnTriggerEnter(Collider other)
{
Debug.Log(other.gameObject.name);
@ -15,4 +16,11 @@ public class ShellBoom : MonoBehaviour
onShellAttack?.Invoke();
}
}
private void Update()
{
if (attackTarget != null)
{
transform.Translate(transform.forward * Time.deltaTime * 70f, Space.World);
}
}
}

View File

@ -210,8 +210,8 @@ public class UnmannedAerialVehicle : MonoBehaviour
if (wrjModel == WRJModel.)
{
Debug.Log("光学无人机攻击");
//StopCoroutine(RangedAttack());
//StartCoroutine(RangedAttack());
StopCoroutine(RangedAttack());
StartCoroutine(RangedAttack());
}
else
{
@ -235,12 +235,11 @@ public class UnmannedAerialVehicle : MonoBehaviour
{
while (attackTarget)
{
yield return new WaitForSeconds(0.5f);
yield return new WaitForSeconds(0.8f);
GameObject obj = Instantiate(bulletPrefab, bulletPoint.position, bulletPoint.rotation);
obj.SetActive(true);
Rigidbody rb = obj.GetComponent<Rigidbody>();
rb.AddForce(bulletPoint.forward * 20f, ForceMode.Impulse);
ShellBoom sb = obj.AddComponent<ShellBoom>();
sb.attackTarget = attackTarget;
sb.isPlayer = unmannedAerialVehicleManage.equipmentCommon.isPlayer;
sb.onShellAttack.AddListener(() =>
{

View File

@ -305,7 +305,8 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
}
if (unmannedAerialVehicles[0].attackTarget == null)
{
SendMsg(c.transform);
if (c != null)
SendMsg(c.transform);
unmannedAerialVehicles[0].AttAck(c.transform);
}
}