nickej

0 answers · asked · Lesson: Using Components · Course: Game C# Programming Bootcamp

How the script communicates with the Rigidbody component?

I'm working with the downloaded Components package, and got curious about how the script communicates with the Rigidbody component. The script is attached to the Ramp GameObject, and the Ball doesn't fall. So far so good. 

I added a Cube, and attached another Rigidbody to it. Same name and all, but it falls, so the Cube Rigidbody isn't getting the message from the script. Maybe only the first Rigidbody applied in the scene gets the script effect?

Then I deleted the Ball Rigidbody, and applied a new Rigidbody to it. Ball has one Rigidbody, but not the original one. Now both the Cube and the Ball fall, so neither is getting the message from the script. 

So, when did the first Rigidbody get associated with the script? When it was attached to the Ball at first? When the script got attached to the Ramp, how did it keep the connection, but lose it when the first Rigidbody was deleted and then reapplied?