麻烦看下怎么回事
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullect : MonoBehaviour {
public float moveSpeed = 10;
public bool isPlayerBullect;//true玩家子弹 false敌人子弹
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Translate(transform.up* moveSpeed*Time.deltaTime,Space.World);
}
private void OnTriggerEnter2D(Collider2D collision)
{
switch(collision.tag)
{
case "Tank":
if(!isPlayerBullect)//敌人子弹
{
collision.SendMessage("Die");
Destroy(gameObject);
}
break;
case "Heart":
collision.SendMessage("Die");
Destroy(gameObject);
break;
case "Enemy":
if(isPlayerBullect)
{
collision.SendMessage("Die");
Destroy(gameObject);
}
break;
case "Wall"://墙体 销毁
Destroy(collision.gameObject);
Destroy(gameObject);
break;
case "Barriar":
Destroy(gameObject);
break;
default:
break;
}
}
}
玩家没事,敌人出来自己就死了