Sword Halo & Arrow to the nearest enemy
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class Arrow : MonoBehaviour
|
||||
{
|
||||
public int Damages = 10;
|
||||
|
||||
public GameObject target;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
transform.position = Vector3.MoveTowards(transform.position, target.transform.position, 20f * Time.deltaTime);
|
||||
if (target == null)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if (collision.CompareTag("Ennemy"))
|
||||
{
|
||||
collision.gameObject.GetComponent<Ennemy>().Life -= Damages;
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user