Grenade Dmg 2D Unity

Hi i am pretty new to unity, and i have never made Explosions, i tried to understand other posts, however i couldn’t use them to get it working, if anyone has any suggestions for what i should put in the “Explode” function let me know!

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Bom : MonoBehaviour
{
    public float sidespeed = 15f;
    public float upspeed = 10;
    public int bombdamage = 50;
    public Rigidbody2D rb;
    public GameObject impactEffect;
    public float delay = 4f;
    public GameObject explosionEffect;

    float countdown;
    bool hasExploded = false;

    void Start()
    {
        rb.velocity = transform.right * sidespeed + transform.up * upspeed;
        countdown = delay;
    }

    void Update()
    {
        countdown -= Time.deltaTime;
        if (countdown <= 0f && !hasExploded)
        {
            Explode();
            hasExploded = true;
        }
    }



    void Explode()
    {


       Instantiate(explosionEffect, transform.position, transform.rotation);
        Debug.Log("Boom!!!");
        Destroy(gameObject);
    }

}

What are you really asking? Does your function work at all or no? What is wrong, what do you want to happen, etc…

Thanks for the reply, my function is working however i want to add a hit detector when the explode function is called and i don’t know how to do that, sorry i have never posted a question so i don’t really know what is usually posted.

So you could instantiate a circle collider2D on collision with enemy, player, or any object or whatever. Check out a video:

That may help. But for posting on the forums, there are some standards to avoid flooding it with questions that have already been asked. Have a relevant title, have a question detailed out. Explain what you have tried, what is happening and what you want to be happening. Show code or screenshots if necessary.