using System.Collections; using System.Collections.Generic; using UnityEngine; public class Bomb : MonoBehaviour { public GameObject player; public GameObject explosionPrefab; public int attackDamage; void Start() { player = GameObject.Find("Player"); } void OnCollisionEnter(Collision collision) { if(collision.gameObject.name == "Player") { Instantiate(explosionPrefab, transform.position, transform.rotation); player.GetComponent().playerHP -= attackDamage; Destroy(gameObject); } } }