탑뷰 슈팅 게임 미니 프로젝트
This commit is contained in:
42
Assets/Scripts/Bullet.cs
Normal file
42
Assets/Scripts/Bullet.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user