Destroying Bullet (Impact Effect)
Hello everyone!
I'm brand new to Unity and coding. I've spent the last few days working on my first project, a 2D side scroller. I hit a few bumps in the road that I've been working to overcome. One of them I was hoping I could get your help with. For my enemies death along with my bullet impact I added an effect. When the event is triggered the animation holds onto the last frame. It looks like I need to destroy the object with a little bit of a delay? I'm not sure how I would go about that and I was hoping for your help/insight.
Thank you!!
This is the code for my bullet...
Answer by TheWiitard · Dec 13, 2018 at 08:00 PM
@yaiie_unity I had the same problem as you and then I figured it out. put this in your instantiate code and delete game object code you might have to tweak the time a little for you speed. This also works for your enemy death effect. just use the second script. impact Effect: GameObject clone = Instantiate(impactEffect, transform.position, transform.rotation); Destroy(gameObject); Destroy(clone,0.35f);
death Effect: GameObject clone = Instantiate(deathEffect, transform.position, Quaternion.identity); Destroy(gameObject); Destroy(clone, 0.35f);
Your answer
Follow this Question
Related Questions
MY effect dont destroy 0 Answers
[SOLVED] How to destroy a cloned object if it object colliding with another cloned object ? 1 Answer
Player falls through destroy collider 1 Answer
GameObject not destroying on Collision 1 Answer
How to make it so when i shoot a zombie the has been spawned, it will destroy it? 1 Answer