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

Boundary Destroyer Script "missing" some objects

Discussion in '2D' started by Deleted User, May 10, 2015.

  1. Deleted User

    Deleted User

    Guest

    Hello,

    I have been working on a 2D Space Shooter game for some time now, and I was poking around today and noticed something odd. In my game I have implemented Object pooling and utilize a simple OnTrigger2D script to disable any game object that passes outside of a large rectangular trigger collider. It has been working well for me I thought, but I noticed today that a few (like 15 out of 200) GameObjects don't get disabled, and continue to travel on and on... Anyone got any ideas what the deal is? btw all objects are moving at the same pace.

    Have a great day!

    PS. should I just use waitforseconds and a simple coroutine to disable after a set time, instead of the current setup???
     
  2. Deleted User

    Deleted User

    Guest

    Well it turns out I think I figured out what is causing the issue. Just in case anyone else runs into this here is what I think is happening.

    The GameObjects that are not being disabled properly are missiles being projected from enemy ships. It appears that when an enemy is right on top of the boundary destroyer collider it can still shoot a missile and the missile will of course be outside of the boundary, and thus the missile gets to drift out into space where no one can here it scream.