Skip to content
Adam Graham edited this page Jan 31, 2022 · 30 revisions

Links

FAQs


Error: Cannot implicitly convert type 'Pipes' to 'Pipes[]'

This error is caused by a simple typo I have seen several people make. In the GameManager.cs script, we have the following line of code in the Play function to find all of the objects in the scene with the Pipes script attached to it:

Pipes[] pipes = FindObjectsOfType<Pipes>();

The error is easily caused if you use the singular version of the function FindObjectOfType rather than the plural version FindObjectsOfType. By using the plural version, it returns an array of pipes Pipes[] whereas the singular version returns one instance of Pipes, hence the error trying to convert between the two. Make sure to use the plural version of the function.

I think part of the confusion stems from "pipes" already being a plural word, even if we only reference one instance of it. The Pipes script represent a single group of pipes, but there are multiple pipe groups within the scene, thus we get an array of them.

Clone this wiki locally