How can I make a gameObject with Boxcollider2d and the Boxcollider2D effects to gameObject A but moving through gameObject B

StackOverflow https://stackoverflow.com/questions/23650414

  •  22-07-2023
  •  | 
  •  

Question

I'm new in unity and i'm trying to buid a 2d game and I want to know how to create a gameobject with boxcollider2d and the boxcollider2D just work when the game hits gameObject A but do not work when interacting to gameobject B.

Était-ce utile?

La solution

Assign your objects to different Layers.

By doing this you can either set them to collide with each other, or to ignore any collisions between them. So make an A layer for all your A objects, and a B layer for all your B objects. (Of course you can name it whatever you like) Go to

Edit > Project Settings > Physics

where you can edit the layer collision matrix, to enable or disable collisions between layer elements.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top