I am new to programming and I am trying to make my tiny bullet hit particle system show when my cloned bullets collide with anything
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bullet : MonoBehaviour
{
//particle prefab
public GameObject impact;
public float speed = 20f;
public int damage = 20;
public Rigidbody2D rb;
// Start is called before the first frame update
void Start()
{
rb.velocity = transform.up * speed;
}
private void OnTriggerEnter2D(Collider2D hitInfo)
{
enemyDamage enemy = hitInfo.GetComponent<enemyDamage>();
//trying to clone the effect for each bullet
impact = Instantiate(impact, transform.position, Quaternion.identity) as GameObject;
if (enemy != null)
{
enemy.takeDamage(damage);
}
Destroy(gameObject);
Destroy(impact, .75f);
}
// Update is called once per frame
void Update()
{
}
}