Search Unity

Question Destroy Animation object after the animation

Discussion in 'Animation' started by SoumyadeepUnitedUnity, Mar 10, 2023.

  1. SoumyadeepUnitedUnity

    SoumyadeepUnitedUnity

    Joined:
    Feb 27, 2023
    Posts:
    1
    Hi Everyone,

    I am new to unity and game development. I am working on a 2D game, where I used a bulletimpact prefab which has an animation, that is not looped. after the bullet hits the animation object stays on the scene, and when I trying the destroy the object unity is throwing the following error:

    upload_2023-3-10_11-54-21.png

    Also the impact clones are staying.

    upload_2023-3-10_11-51-10.png

    upload_2023-3-10_11-52-42.png
     

    Attached Files:

  2. Unrighteouss

    Unrighteouss

    Joined:
    Apr 24, 2018
    Posts:
    599
    How are you trying to destroy the object?

    The error is likely because you're trying to destroy the root prefab, and not the instances of that prefab.

    If you're struggling to fix this, please show the code or whatever method you're using to destroy the objects.