A general question about Unity. I’m a bit surprised that you get a handle to a GameObject by:
foreach (Pin pin in GameObject.FindObjectsOfType<Pin>()) {
Mostly as there is no “pin” object; there is a pin script however. Not only that, even if you did get the script directly, it seems to know that there is a rigidbody attached, or we wouldn’t have the transforms.
Not only that, I have Gnomes instead of pins, and I figured I’d have to change this line of code. The pin is a script component to the GameObject “Gnome”.
The code ran fine as is.
So, if I had two different objects, one is “Pin” and the other is “Gnome” but both “has a” script called Pin, FindObjectsOfType works for either?
Seems odd.
To further add confusion, in the shredder we have:
GameObject thingLeft = collider.gameObject;
if (thingLeft.GetComponent<Pin> ()){
Destroy (thingLeft);
which seems to be more of a “HasA” which is what I’d expect.
== John ==
P.S. This is why I take these courses, I would have been stumped for days over this one