Hello all,
I'm working on a top down shooter iOS 2D game and I'm having some problems with destroying the bullets the spaceship shoots. This is what I have done so far:
1. Created a top bumper. It's a sprite with a Box Collider 2D attached. It is also on its own shorting layer behind the foreground and in-front of the background (Z position is 0, the shame as spaceship).
2. Made the bullet, which is a prefab, a Rigid Body 2D component (with 0 Gravity Scale) and also applied a Box Collider 2D (I also tested without the Box Collider 2D and only with the Rigid Body 2D but in this case the bullet does not collide on the top bumper at all).
3. On the bullet prefab I attached the following script:
function OnCollisionEnter(col : Collision){
if(col.gameObject.tag == "Top"){
Destroy(gameObject);
}
}
*Note that I have assigned the top bumper a "Top" tag.
So what I ended up with is a bullet that when it reaches the top bumper, it collides to it and stays there or moves weirdly along the bumper, but it is not destroyed. See image:
![alt text][1]
I believe it may have something to do with the 2D components and the colliders I use, as this is my first 2D game and I'm not accustomed to this workflow.
Please help out if you are experienced with 2D, cause I don't seem to be able to find a solution about this.
Thank you so much!
[1]: /storage/temp/20831-bullet_problem.jpg
↧