using System.Collections; using System.Collections.Generic; using UnityEngine; public class Projectile : MonoBehaviour { void Start() { } public void OnCollisionEnter(Collision collision){ var bot = collision.collider?.transform.root.GetComponent(); if(bot != null){ bot.hit(); } Destroy(this.gameObject); } }