- Home /
Yet Another 2D Collider Question
I am trying to make a projectile that deletes itself upon collision. I do not think any collisions are occuring. In Image 1, you can see a white ball which is firing small white balls at the maroon boundary. The balls stop at the maroon boundary and kind of "vibrate" while their x position continues to increase in their Transform component.
The projectiles have rigidbody2D and a collider (image 2). The boundary has a collder.
The layers are both 0, and that layer is enabled in the layer collision matrix.
The projectiles have the following in their script:
void OnCollisionEnter2D(Collision2D col)
{
Debug.Log("Text: Collision Detected");
Destroy(gameObject);
}
No log is written when they stop and vibrate at the boundary. Any ideas?
Answer by Hawaii_Dev · Apr 28 at 07:39 AM
It seems that in image 1 the projectile doesn't actually have the correct components attached as shown in image 2. Could you share your code that instantiates the projectiles as I imagine you aren't instantiating the correct prefab.