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);
}
}