Search Unity

Box2D collider not stopping my player

Discussion in 'Getting Started' started by warrenbrandt, Jul 31, 2019.

  1. warrenbrandt

    warrenbrandt

    Joined:
    Mar 3, 2018
    Posts:
    413
    i have 4 box colliders around my player but its not stopping the player from leaving the screen
    how do you control when they collide etc, i tried layers but that doesnt do anything
     
  2. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    657
    Screens dont just magically have collision boundaries. Also... What do you mean 'around your player'...

    Are you using a rigid body?

    More info needed
     
  3. warrenbrandt

    warrenbrandt

    Joined:
    Mar 3, 2018
    Posts:
    413
    yes my player has a rigid body and a poly colider
    i have 4 box2d coliders around the borders of the screen but my player passes through them
    where is collision handled ie what will collide with what in Unity?
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Colliders are attached to GameObjects and GameObjects are placed at world space coordinates. They don't have anything to do with the edge of the camera you are displaying on the screen unless you write a script to move them with the camera. Maybe you're just stating the issue wrong, and it has nothing to do with the edge of the screen? If so, try stating the exact issue more clearly (colliders and the screen have pretty much nothing to do with each other, so the way you are stating your issue is confusing - like saying you are having trouble starting your car because it says your tire pressure is low)

    But make sure your colliders aren't set to trigger, make sure your collider settings will result in a "Y" in the below linked collision matrix when they collide with each other.
    https://docs.unity3d.com/Manual/CollidersOverview.html