- Home /
OnCollisionEnter2D in a puzzle game with each block snapped to a grid?
I have objects which are snapped to a grid. Each cube object is 0.64x0.64 in size. The border of the gameplay window is also just grey cubes snapped to a grid, with each grey cube being 0.64x0.64 in size.
I have an issue where a collision is detected with OnCollisionEnter2D when the level starts with the cubes in their place. For example, when the level starts the cubes are at rest but a collision is detected between the border cubes and the red cubes.
How can I go about preventing this?
Answer by bombombambam · Jun 12, 2020 at 08:30 PM
Put the cubes you want to collide with and the rest to separate layers and in Edit -> Project Settings -> Physics -> Layer Collision Matrix disable collision between the two layers.
I want them to collide though. I just don't want a collision triggered when they are stationary.
Try to scale down the colliders, so they don't touch.