[Help] Phantom triggering of Lose Collider

Hi all, Sorry if this is a duplicate issue but I couldn’t see it anywhere.

I have an issue where I load a level, the ball is attached nicely to my paddle but if I leave it there for 5-10 seconds (either stationary or moving with the mouse), my Lose screen suddenly loads.

It seems that my lose collider is being triggered by something after a period of time, as if something invisible is falling very slowly under gravity from the top of the screen or something. I added the following line of code to print collision detail to the console :

using UnityEngine.SceneManagement;

public class LoseCollider : MonoBehaviour {

    private void OnTriggerEnter2D(Collider2D collision)
    {
        Debug.Log("LoseCollider Has been Struck by " + collision.name);
        SceneManager.LoadScene("Lose Screen");
    }
}

and the console then tells me it is the ball!
image

How can that be? My ball is still sat right there on top of my paddle?

After further investigations, the problem occurs when the gravity setting in my Project’s Physics2D is set to a negative value (including the default Y=-9.81). If I set it to zero or a positive number such as Y=1, the problem disappears.
This is a workaround but not a solution. Any ideas on why this is happening?

Hi Martin,

Could you maybe upload your project here or somewhere we could access it? I don’t understand why that could be happening so I’d like to see this bug for myself :wink:

BallBuster.zip (4.4 MB)

Apologies if this is too big - admin please delete if it is…

  1. Open Level 1
  2. Play
  3. Wait (do not click mouse button to launch ball)

I think this forum accepts files up to 10 MB, so you should be fine on that front.

As for your problem, well… it’s a real head-scratcher (at least for me). I think I’m close to finding the reason behind it, but I’ve been thinking about it for more than an hour and the headache is getting strong, so I’ll resume my investigation in the morning :wink: I’ll share my thoughts on it so far though:

  1. setting the collision detection mode on the ball’s rigidbody2d to continuous instead of discrete gets rid of the problem, so that’s a possible quick and dirty fix.

  2. if you change the Update function to FixedUpdate, you can actually see the ball fall through the paddle and down to the lose collider. You can also see the effect of the continuous collision detection that way.

  3. from this, I assume that it HAS to have something to do with the physics update and the frame update being out of sync. Somehow Unity thinks the ball falls through the paddle while still showing the ball neatly sitting on top of it.

I don’t know how or why any of this is happening (yet), maybe someone else can come along and explain it, or the solution will come to me in a dream – that would be nice.

Sorry if I’m not making sense right now, it’s midnight here and I need to go to sleep :slight_smile:

1 Like

That makes a lot of sense - thank you for taking a look.

I’ll play with these things further in the morning, and hopefully in the meantime your dreams will reveal the solution :joy:

Privacy & Terms