#How do I find the closest object out of multiple?

1 messages · Page 1 of 1 (latest)

icy dome
#
lightSwitch = FindObjectOfType<LightSwitch>();
lightSwitch.unlockCamera();

I have this code to find an object of type LightSwitch, but if there are multiple with that type, how do I just find the one closest?

peak sandal
icy dome
#

You mean like make an array and cycle through it to find the closest?

peak sandal
icy dome
#

Actually I'm now realizing I forgot to set it to check if it's hitting an object of type LightSwitch in the first place