вот скрипт 1 обьекта
using UnityEngine;
using System.Collections;
public class EnemyScript : MonoBehaviour
{
public int health = 2;
public GameObject boom;
public int damage = 1;
void Start()
{
boom = GameObject.Find("Boom");
}
void OnTriggerEnter2D(Collider2D collider)
{
if (collider.gameObject.tag == "Bullet")
{
GetComponent<AudioSource>().Play();
health = health - 1;
}
if (health <= 0)
{
GameObject.Find("EnemySpawn").GetComponent<GameController>().KilledEnemy();
boom.transform.position = new Vector2(transform.position.x, transform.position.y);
boom.GetComponent<ParticleSystem>().Play();
boom.GetComponent<AudioSource>().Play();
Destroy(gameObject);
}
}
}
и второй скрипт
using UnityEngine;
using System.Collections;
public class Bullet : MonoBehaviour
{
public float lifetime = 2.0f;
public float speed = 5.0f;
public int damage = 1;
// Use this for initialization
void Start()
{
Destroy(gameObject, lifetime);
}
// Update is called once per frame
void Update()
{
transform.Translate(Vector3.up * Time.deltaTime * speed);
}
void OnTriggerEnter2D(Collider2D collider)
{
if (collider.gameObject.tag == "Enemy")
{
Destroy(gameObject);
}
}
}
и что не так?