16 lines
453 B
C#
16 lines
453 B
C#
using UnityEngine;
|
|
|
|
public class ObjectHit : MonoBehaviour
|
|
{
|
|
[SerializeField] int damageAmount = 10;
|
|
private void OnCollisionEnter(Collision other)
|
|
{
|
|
if (other.gameObject.tag == "Player" && gameObject.tag != "Hit")
|
|
{
|
|
GetComponent<MeshRenderer>().material.color = Color.black;
|
|
gameObject.tag = "Hit";
|
|
other.gameObject.GetComponent<PlayerStats>().TakeDamage(damageAmount);
|
|
}
|
|
}
|
|
}
|