43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using UnityEngine;
|
||
|
||
public class Bullet : MonoBehaviour
|
||
{
|
||
public float speed = 10;
|
||
public float damage = 1;
|
||
Vector2 direction;
|
||
public Vector2 Direction
|
||
{
|
||
set
|
||
{
|
||
direction = value.normalized;
|
||
}
|
||
|
||
}
|
||
|
||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||
void Start()
|
||
{
|
||
// <20><EFBFBD>Ʈ <20>ڵ<EFBFBD>
|
||
//this.Direction = new Vector2(10, 1);
|
||
}
|
||
|
||
// Update is called once per frame
|
||
void Update()
|
||
{
|
||
transform.Translate(direction * speed * Time.deltaTime);
|
||
}
|
||
|
||
private void OnTriggerEnter2D(Collider2D collision)
|
||
{
|
||
if (collision.tag == "Wall" || collision.tag == "Enemy")
|
||
{
|
||
//// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ<EFBFBD><C6AE> Instantiate<74><65> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>ε<EFBFBD><CEB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
||
//Destroy(gameObject);
|
||
|
||
// ObjectPool<6F><6C> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Instantiate<74><65> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ʱ<EFBFBD>ȭ
|
||
gameObject.SetActive(false);
|
||
|
||
}
|
||
}
|
||
}
|