Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Line Renderer Destroying an object twice

Discussion in '2D' started by unity_ZPlV8AKIn1zXsA, Aug 4, 2019.

  1. unity_ZPlV8AKIn1zXsA

    unity_ZPlV8AKIn1zXsA

    Joined:
    Jun 29, 2019
    Posts:
    1
    i am using line Renderer to destroy some objects and increase the score. But sometimes line destroys same object twice. I added box collider to line in script and if an object With a tag has collision With line the object will be destroyed. But it is destroyed twice. How can i fix this problem.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,314
    So it's not the LineRenderer destroying objects (as you're indicating) but your script doing so. By the sound of it, and it's far from clear, you have code in an OnCollisionEnter2D callback (?) which deletes an object but you get two of these callbacks on the same object even though you've destroyed it? That sound very odd and I don't see how that can happen.

    You should provide more detail on what these physics objects are and a code-snippet of what you're doing in the callback.