MY effect dont destroy
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class bulletController : MonoBehaviour
{
public float moveSpeed = 20f, lifetime;
public Rigidbody rb;
public GameObject impactEffect;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
rb.velocity = transform.forward * moveSpeed;
lifetime -= Time.deltaTime;
if(lifetime <= 0)
{
Destroy(gameObject);
}
}
void OnCollisionEnter(Collision collision)
{
Destroy(gameObject);
Instantiate(impactEffect, transform.position, transform.rotation);
}
}
Comment