how to check if position have gameobject ?

is it able to check if position have gameobjects ? or is there a function for this in JavaScript?

There are certainly a number of ways of achieving this however Molix posted the easiest and most common way to go about. As Molix says, this puts an assumption that all your interesting objects have a collider attached.

Another way of checking if an object is near a place is to test each objects position if it is inside a sphere or some other volume. You can use Vector3.Distance to get the distance of two points in space, and then check if the distance is less than your radius. If it is, then its selected. This would only check against a single point, such as the pivot of your transform.

Yet another way is to check Renderer.bounds (See also Bounds), if you are interested in visible objects.

In both of the ways I described here, you'll need to get hold of some game objects to start with.

  • The simplest and also most inefficient way is to get all objects with Object.FindObjectsOfType and test them.

  • A less inefficient way might be to get objects with a certain tag calling GameObject.FindGameObjectsWithTag, if you know all your objects have a certain tag.

  • A better approach would be then to implement your own (or find an existing solution of) spatial database, such as a Octree, Quadtree, BSP, Morton Coding or other techniques. I won't go in details on those, but I left you some keywords to type into google.

If you want to get something efficient going quickly, go for Molix answer. Just know what kind of data you want to test against.

You could ensure that the objects you want to look for have colliders, and then do a Physics.SphereCast at a specified position. The link has some examples.

Edit: oops, yes I meant OverlapSphere.