All the walls light up on game start

Hi everyone!

Had an issue with this lesson. I did find the solution, but i still want a deeper dive on the case.
The case:
Did everything like on the video:

  1. Made the walls surrounding the arena with rigidbodies and the material.
  2. Created the script for collision check and material color change.
  3. On play found out that all the walls light up as soon as the game started.

The versions i troubleshooted:

  1. Walls drop on or collide with the plane at the start of the game
    I checked the rigid body - the gravity was on, the position and rotation frozen.So the walls didn’t drop.
    I changed the position of plane and the walls by Y axis, so that they are not collided. The walls continued to light up.

  2. Walls collide with each other on the start of the game
    So that actually was the issue. The walls collided and changed their color.
    The way i solved the case was to leave a tiny distance between the walls in the corners of the arena.

So what i would like to know is why did this happen?
In the video i clearly see that Rick has his walls collided, but he does’t have the same issue. The walls light up on collision with the player. So what is the difference? Why do my walls light up at the start of the game due to collision with each other?

I use Unity version 2021.3.10f1.

Hi Sergey,

Only the player and moving/moveable objects are supposed to have a Rigidbody component attached. The ground and the walls must not have a Rigidbody component attached to their inspector. For a collision event, we need at least one Rigidbody. Since the ground and the walls are not supposed to collide with one another, they are not allowed to trigger collision events between them. This means: no Rigidbody for them.

Please check the Inspector of your game objects and make sure they have only the required components attached, not anything else.

Did this help you fix the issue? :slight_smile:


See also:

2 Likes

Thank you for the solution!
I did have rigid bodies in the walls inspector!
But i did solve the issue everything is ok :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms