Search Unity

Collider only affect main character

Discussion in '2D' started by michelmarmonemarini, Feb 23, 2019.

  1. michelmarmonemarini

    michelmarmonemarini

    Joined:
    Feb 23, 2019
    Posts:
    3
    hello i'm making a 2d game and i would like to put invisible wall on each side of my map to block the character and i would like that my others objects can go trough all those walls.
     
  2. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    Hi @michelmarmonemarini

    You didn't pretty much tell anything about your setup...?

    What is your setup, how have you setup you collisions, are you using collider2D's or colliders and so on.

    But if you are using 2D or 3D Physics system, you could just add cubes, then add colliders to these cubes, then just hide mesh renderers of these objects. You could also just add empty GameObjects, but this way you don't have to adjust collider sizes as they will fit automatically to your cube shape.

    If you were to use / create tile based system, you could get rid of colliders all together, and just use 2D array of 0's and 1's to let player know if he can enter a tile or not.

    To prevent just player going through walls, use collision layers, with last mentioned system, you don't even need that, just some condition.
     
    michelmarmonemarini likes this.
  3. michelmarmonemarini

    michelmarmonemarini

    Joined:
    Feb 23, 2019
    Posts:
    3
    Thank you for your answer.
    So i have a character with a Sprite, RigidBody2D, Circlecollider2D. My platform have a sprite and a boxcollider2d, So I have an object that is a ball with a CircleCollider2d and a RigidBody. The platform dont have borders so the character can actually fall. So i want the character to not fall when he reach the border. So i thinked about putting invisible walls but the problem is that my objects are spawning out of the walls so i need to find a way to let the acces for the ball to go trough those walls, but my character cant go trough those walls.
     
  4. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    dschu and michelmarmonemarini like this.
  5. michelmarmonemarini

    michelmarmonemarini

    Joined:
    Feb 23, 2019
    Posts:
    3
    @eses
    Thank you !! It's work !