Skip to main content

Detecting Collisions

The OnCollisionEnter method can be used to detect a collision of a GameObject with another GameObject. In this example we are also using the GetComponent<Renderer>() method to access the object's renderer component, which controls its visual appearance.

We create a new script with the name ChangeColorOnCollision