This should be an easy one:
GameObject myCube = GameObject.Find("Cubey").GetComponent<GameObject>();
just kicks up error CS0309: The type UnityEngine.GameObject must be convertible to UnityEngine.Component in order to use it as parameter T in the generic type or method UnityEngine.GameObject.GetComponent()
Normally the errors Unity displays are useful, but this is just confusing. Are cubes not GameObjects? Any pointers would be appreciated (no pun intended).
GameObject
is not a component. A GameObject
has a bunch of Component
s attached to it.
You can take away the GetComponent
call and just use the result of your Find("Cubey")
GameObject myCube = GameObject.Find("Cubey");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With