Lose Collider triggering for no reason

After watching this lecture and seeing Rick turning on and off the Lose Collider, I decided to turn mine back on. I’ve noticed a strange issue though, it’s being triggered for some unknown reason!

When I press play:

  • I get a few seconds of gameplay before it’s triggered.
  • It only happens if I DON’T launch the ball.
  • I’ve added a Debug.Log to the Lose Collider to check it’s definitely the thing being triggered, it is.
  • It can only be triggered by something else with a collider but there are no colliders seemingly interacting with the Lose Collider on play.

Any advice on how to find or stop the issue would be great! :slight_smile:

Will need more info to be able to help. A picture of your hierarchy and your formatted code would be good.

Hi David, hopefully these images help out :slight_smile:


Hi Oli,

Please note, it’s better to copy/paste your code and apply the code fencing characters, rather than using screenshots. Screenshots are ideal for displaying specific details from within a game engine editor or even error messages, but for code, they tend to be less readable, especially on mobile devices which can require extensive zooming and scrolling.

You also prevent those that may offer to help you the ability to copy/paste part of your code back to you with suggestions and/or corrections, meaning that they would need to type a potentially lengthy response. You will often find that people are more likely to respond to your questions if you make it as easy as possible for them to do so.

Hope this helps :slight_smile:

See also;

Yeah, very strange. From what I can see nothing looks wrong, the only suggestion I have is to double check all your items in your hierarchy maybe you have the lose collier script on something else as well.

Even though it shouldn’t be moving, are you sure the ball isn’t rolling off the paddle and then hitting the lose collier? Only thing else I can think of.

Click here to reveal code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class LoseCollider : MonoBehaviour
    private void OnTriggerEnter2D (Collider2D collision)

       Debug.Log(collision.transform.name);   // this should tell you what is triggering it.

 if (collision.transform.name == "Ball") 


While I don’t know what is causing it this should prevent it from happening, the debug.log should also tell you what is colliding with it.

Edit: Sorry if the format of the code looks messy it’s hard to do it in the forums normally i would just copy and paste from VB, also good luck hopefully this helps.

Why not log the other object to see what is colliding?

1 Like

When you do get around to it do let us know what the Debug.Log revealed. I’m curious as to what was colliding with it.

Thanks for the responses and I’m very sorry to not getting back sooner. After another couple of lessons, the issue has actually stopped! I didn’t get a chance to add Debug.Log(collision.gameObject.name); to the script but thanks for the prompt, something I’ll definitely remember in future!

I have a feeling there may have been something wrong with my blocks, after adjusting them and creating a prefab etc, the issue didn’t return. Sorry I can’t provide any real conclusion on this, but thanks for the advice! Awesome and helpful community :slight_smile:

1 Like

If the ball collides with the lose collider even though is has not been launched, please try the following in your Ball.cs:

void Start ()
    paddleToBallVector = transform.position - paddle1.transform.position;
    myAudioSource = GetComponent<AudioSource>();
    myRigidBody2D = GetComponent<Rigidbody2D>();
    myRigidBody2D.simulated = false; // <-------- add this
private void LaunchOnMouseClick()
    if (Input.GetMouseButtonDown(0))
        hasStarted = true;
        myRigidBody2D.velocity = new Vector2(xPush, yPush);
        myRigidBody2D.simulated = true; // <-------- add this

That should hopefully fix the issue. :slight_smile:

See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms