For those having problems with Collision / Player going through walls

Hi,

I had reached the Incrementing A Score lesson with no problems so far. When asked to create a new obstacle: instead of duplicating my wall/boundary I created a new 3D object/Cube and placed it on my plane/playing field. When I clicked PLAY I found my player was going through my new Cube.

I compared my Cube obstacle with my walls (which were working) and couldn’t find what was going wrong.

I duplicated a wall section instead (as Rick did) and that worked fine. I still couldn’t work out why my created cube wasn’t working and the player was going through it.

I figured it must be something to do with the box colliders but looking at it in 3D view - the box colliders looked fine - it was definitely there and ‘on’ so why wasn’t it working??

I then tried 2D view and noticed that my box collider/cube was lower /below the plane than my walls.

Even though the player’s box collider looked like it should be ‘colliding’ with the obstacle’s box collider because the Cube/ Cube box collider was set slightly too low the game was having trouble recognising it?

Simple solution: Move the cube/obstacle up (Y axis) until it aligned with the plane

It now works.

Thought this might help some people who are finding their player is going through walls when it shouldn’t be.

If you compare the images below - the first image shows it when the player (in yellow) was moving through the cube (white) and not colliding correctly. Note: the blue obstacles work fine (because they were duplicated from the walls which worked - then reshaped).

The second image (below the first) is when it works properly.

Notice how the 3D view for both (in Game) looks identical - it’s only in 2D that the difference (position of white cube on Y axis) is obvious.


2 Likes

Thank you for this! People will find this extremely helpful.

Privacy & Terms