34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class BulletController : MonoBehaviour{
|
|
|
|
public float speed;
|
|
|
|
// Update is called once per frame
|
|
void Update(){
|
|
transform.Translate(Vector2.right * speed * Time.deltaTime);
|
|
}
|
|
|
|
void OnTriggerEnter2D(Collider2D col){
|
|
if(col.gameObject.tag == "Enemy"){
|
|
ObjectPooler.Instance.SpawnFromPool("BulletImpact", transform.position, Quaternion.identity);
|
|
gameObject.SetActive(false);
|
|
}
|
|
if(col.gameObject.tag == "BigEnemy"){
|
|
ObjectPooler.Instance.SpawnFromPool("BulletImpact", transform.position, Quaternion.identity);
|
|
}
|
|
if (col.gameObject.tag == "CircleEnemy"){
|
|
ObjectPooler.Instance.SpawnFromPool("BulletImpact", transform.position, Quaternion.identity);
|
|
}
|
|
if (col.gameObject.tag == "RocketEnemy"){
|
|
ObjectPooler.Instance.SpawnFromPool("BulletImpact", transform.position, Quaternion.identity);
|
|
gameObject.SetActive(false);
|
|
}
|
|
if (col.gameObject.tag == "Wall"){
|
|
ObjectPooler.Instance.SpawnFromPool("BulletImpact", transform.position, Quaternion.identity);
|
|
gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|