mirror of
https://github.com/Steffo99/mission-failed.git
synced 2024-12-04 22:04:17 +00:00
19 lines
460 B
C#
19 lines
460 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class DamageOnHit : MonoBehaviour
|
|
{
|
|
public string targetTag;
|
|
public int damage = 1;
|
|
|
|
void OnCollisionEnter2D (Collision2D collision)
|
|
{
|
|
GameObject collidedObj = collision.gameObject;
|
|
if (collidedObj.CompareTag(targetTag))
|
|
{
|
|
HealthController healthController = collidedObj.GetComponent<HealthController>();
|
|
healthController.Damage(damage);
|
|
}
|
|
}
|
|
}
|