Search Unity

Halpern's tutorial -- box collider issues

Discussion in 'Editor & General Support' started by CaptainAfrica, Aug 5, 2019.

  1. CaptainAfrica

    CaptainAfrica

    Joined:
    Aug 5, 2019
    Posts:
    5
    Hi guys I am very new to Unity and picking up the basics.

    Going through Jared Halpern's Developing 2D Games with Unity tutorial. Player does not collide with background objects, and I think it is the issue of the box collider as I followed instructions (Ch. 1-4) to create colliders with the background objects. However, when I try to make it bigger like around .0025 so the collider is "big enough", she gets pushed up to the top of the map and I cannot move downwards. When I read in the tutorial the author did not want more editing of the box collider to this point. Video attached for further details.



     
    Last edited: Aug 5, 2019
  2. bowserscastle

    bowserscastle

    Joined:
    Jul 9, 2017
    Posts:
    14
    Hi there - thanks for checking out my tutorial!

    There's a simple fix. Select the Ground Layer (probably called "Layer_Ground") and in the Inspector, check the: "Is Trigger" box on the Polygon Collider 2D component. We want to use the collider as a trigger, not as something that the player runs into. What's happening in your video is that the player starts inside the collider, and since the "Is Trigger" box isn't selected, Unity looks at the collider as if it's something that the player physically ran into. So when the player "runs into" the collider, the player gets pushed out - thus, the player appears outside of the box very quickly and can't get back inside. Checking "Is Trigger" on the collider component will fix this.
     

    Attached Files: