【unity 保卫星城】--- 开发笔记
~~ 战机武器库 ~~
3.追踪导弹
参考大佬的博客:https://blog.csdn.net/sdhexu/article/details/77962134
(写了个2D的出来)
由武器管理系统,控制子弹生成:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace ns
{
///<summary>
///
///</summary>
public class GuideMissiles : Weapons
{
private GameObject go;
private GameObject temp;
private float t = 0;
public float timer = 1f;
public GuideMissiles()
{
weaponName = "GuideMissile";
attack = 150;
bulletCount = 1;
rate = 0.5f;
Update();
}
/// <summary>
/// 发射的方法
/// </summary>
public override void Launch(GameObject _airPlane)
{
if(bulletCount > 0)
{
if (time >= rate)
{
if (temp == null)
{
PoolManager.GetInstance().GetObj(weaponName, (obj) =>
{
temp = obj;
temp.SetActive(true);
temp.transform.position = new Vector3(_airPlane.transform.position.x, _airPlane.transform.position.y - 0.15f, 0);
temp.transform.rotation = new Quaternion(0, 0<