I would like to have gameobjects on a scene scattered around but I would like one selected objects which I can colour or delete but I also would like to switch objects with the arrow keys and I’m not sure how to switch to the next object, ie.
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, out hit)) {
var n = hit.transform.name;
if( n == transform.name && Input.GetKeyUp("a")){
selectedc = ?????
selectedc.transform.GetComponent<Renderer>().material.color = new Color(0.1f, 0.0f, 0.5f);
}
}
That would select the object closest the left of the object and I would need to change hit to selectedc.
Also in a 3dimensional view if Im looking at a pyramid of objects from the topview down I would like to select the top most object of them when I go left, ie. The closest to the camera. I dont want to go deeper, I want closer to camera.
Any clues appreciated thanks!