Sword Halo & Arrow to the nearest enemy

This commit is contained in:
2023-10-17 10:55:31 +02:00
parent eb51da13ed
commit ec1084bd10
23 changed files with 1097 additions and 3 deletions
+27
View File
@@ -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);
}
}
}