I am wanting to see a script that locates the nearest gameobject to the gameobject the script is attached to. (Which would likely be the player). The gameobject must be on the player’s screen and also must be the closest to them. Because I don’t want it targeting gameobject’s that the player can’t see. Can you show me a working code example of this?
Here is some pseudo code to demonstrate what I am talking about somewhat:
var Target
for(GO:GameObject in GetCircle(gameObject,10 meters))
Target=GO
return
GetCircle is the hypothetical function that returns all game objects in a circle around arg1, within a distance of arg2.
Thanks