Search Unity

Bug Unity collision messed up - my player collide with anything!!

Discussion in 'Editor & General Support' started by NicoBacc, Jan 22, 2021.

  1. NicoBacc

    NicoBacc

    Joined:
    Dec 10, 2020
    Posts:
    18
    Hi guys,
    today while I'm testing my game, I found a strange behaviour. The collision on a portion of the road are completely messed up. Even if I remove the road prefab or the box collider, my car collides with something. In the editor I cannot see anything below it. What could be happened? Is there a way to recalculate all the collider of the object?

    As you can see in the picture below, the car doesn't fall down but collide with something invisible. Any ideas?

    upload_2021-1-22_11-12-37.png
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,691
    I would turn on wireframe view in the scene, press PLAY, look closely at your car and and start deleting stuff in your scene while the game runs. Eventually you will delete what you are colliding with, IF you are truly colliding with something.

    Otherwise, to help gain more insight into your problem, I recommend liberally sprinkling Debug.Log() statements through your code to display information in realtime.

    Doing this should help you answer these types of questions:

    - is this code even running? which parts are running? how often does it run?
    - what are the values of the variables involved? Are they initialized?

    Knowing this information will help you reason about the behavior you are seeing.
     
    Joe-Censored likes this.
  3. NicoBacc

    NicoBacc

    Joined:
    Dec 10, 2020
    Posts:
    18
    Thanks for your answer, I started deleting stuff in my scene while the game runs and I found that there was a cube without mesh which has a box collider. Now the problem is fixed!
     
    Kurt-Dekker and Joe-Censored like this.