mirror of
https://github.com/kuhyx/praca_magisterska.git
synced 2026-11-26 03:27:17 +01:00
21 lines
510 B
C#
21 lines
510 B
C#
using UnityEngine;
|
|
|
|
public class Enemy : MonoBehaviour
|
|
{
|
|
public float speed = 2f;
|
|
|
|
void Update()
|
|
{
|
|
transform.Translate(Vector3.down * speed * Time.deltaTime);
|
|
if (transform.position.y < -10) Destroy(gameObject); // Out of bounds
|
|
}
|
|
|
|
void OnTriggerEnter2D(Collider2D other)
|
|
{
|
|
Debug.Log($"Enemy hit: {other.name} with tag: {other.tag}");
|
|
if (other.gameObject.GetComponent<Player>() != null)
|
|
{
|
|
Destroy(other.gameObject);
|
|
}
|
|
}
|
|
} |